DEV Community

Russell Jones
Russell Jones

Posted on • Originally published at jonesrussell.github.io on

Quickly View Project Dependencies on the CLI

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
Enter fullscreen mode Exit fullscreen mode

List Only Direct Dependencies

npm ls --depth=0
Enter fullscreen mode Exit fullscreen mode

List Production Dependencies Only

npm ls --prod --depth=0
Enter fullscreen mode Exit fullscreen mode

List Development Dependencies Only

npm ls --dev --depth=0
Enter fullscreen mode Exit fullscreen mode

Search for Specific Package

npm ls package-name
Enter fullscreen mode Exit fullscreen mode

View Outdated Packages

npm outdated
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)