Update (2025): This article has been revised to reflect modern npm capabilities. The original custom tool is no longer necessary as npm now provides these features out of the box.

Ahnii!

Need to check package.json dependencies without leaving the terminal? Here are the modern ways to do it using npm’s built-in commands.

Built-in NPM Commands

List All Dependencies

npm list
# or shorter
npm ls

List Only Direct Dependencies

npm ls --depth=0

List Production Dependencies Only

npm ls --prod --depth=0

List Development Dependencies Only

npm ls --dev --depth=0

Search for Specific Package

npm ls package-name

View Outdated Packages

npm outdated

Enhanced Features with npm@7+

Newer versions of npm include additional helpful commands:

# View package details
npm view package-name

# View all package versions
npm view package-name versions

# Check for security vulnerabilities
npm audit

Legacy Custom Tool

Note: The custom CLI tool from the original post is no longer necessary with modern npm versions, but you can still find it in the GitHub repository if interested.

npm’s built-in commands now provide robust dependency management features right out of the box. No extra tools needed.

Baamaapii