Skip to content

Latest commit

 

History

History
75 lines (62 loc) · 1.58 KB

npm_and_yarn.md

File metadata and controls

75 lines (62 loc) · 1.58 KB

What version of this package is installed?

npm ls <package_name>
yarn list <package_name>

What versions of this package are available?

npm info <package_name> versions
yarn info <package_name> versions

When were different versions of this package released?

npm view <package_name> time [--json]

What are the dependencies of this package?

yarn info <package_name> dependencies

Which packages depend on this package, aka why is this package installed, aka reverse deps?

npm ls <package_name>
yarn why <package_name>

Which packages have vulnerabilities, and should be upgraded?

npm audit
yarn audit

Upgrade packages selectively / interactively

npx npm-check -u
yarn upgrade-interactive

To ignore semver:

yarn upgrade-interactive --latest

Installing different versions of node

nvm is a popular solution.

fnm is a modern alternative with similar goals.

Clean cache (to reclaim disk space)

du -sh "$HOME"/.npm/_cacache
npm cache clean
du -sh "$(yarn cache dir)"
yarn cache clean

If you use nvm that also has a cache folder (although it seems to manage it quite well itself)

du -sh "$(nvm cache dir)"
du -sh "$NVM_DIR"/.cache
nvm cache clear

You can also remove some node_modules from old projects:

cd
# Largest first (quick)
npx npkill -s size
# Alphabetically (thorough)
npx npkill

Navigate with up/down keys, and press <Space> to remove the focused node_modules folder.