NodeJs
Commands
Package initialization. npm init-y or npm init-f
Opening a package’s homepage. npm home “your-package”
Opening a package’s GitHub Repository. npm repo “your-package”
List all the installed packages. npm ls - - depth 0
List the available scripts. npm run
Check packages that are not declared in package.json. npm prune. This command will run through your package.json file and compare its content with the /node_modules content. You will receive as an output a list of all those packages that are not in the package.json file. After doing this, npm prune will remove those packages together with those which you haven’t added manually to package.json or that were npm installed without the --save flag.
Bump a package version. npm together with minor/major/patch
Running a test. npm run test or npm t
Others:
Update packages: npx npm-check -u
Outdated packages. npm outdated. Add -g for global packages
Package installation. npm i package
Global package installation. npm i -g package
Package installation + saving as a dev dependency. npm i -D pkg
Package installation + saving as a dependency. npm i -S package
npx
Starting with npm 5 - npm i
will save by default (-S
is redundant).
Updating packages
npm install
npm audit fix or npm audit
npm outdated
npm update --save package_name
npm install lodash@latest --save
npm update -g will apply the update action to each globally installed package that is outdated – that is, has a version that is different from latest
To update packages:
https://stackoverflow.com/questions/16525430/npm-check-and-update-package-if-needed
https://www.npmjs.com/package/npm-check or npx npm-check -u
https://www.npmjs.com/package/npm-check-updates
Last updated
Was this helpful?