Skip to main content

NPM CheatSheet for Developers

Basic Syntax of Node Package Manager

CommandDescription
npm initInitialize a node.js project
npm install
npm i
Install package.json dependencies
npm install --global [package]
npm i -g [package]
install package globally
npm install-latest-npmUpdate npm
npm runList available scripts to run
npm run barRuns the script named bar
npm testRuns the projects tests
npm listFor Local packages
npm un <package_name>
npm uninstall <package_name>
Uninstall package from project
npm -g uninstall <name> Uninstall global package
npm update -g <package_name> Update individual global package(s)
npm up <package_name>Update npm package
npm list -g --depth-0List globally installed packages
npm-windows-upgradesUpgrade npm on Windows
npm outdated -g --depth-0Updated global packages
npm alias default 16Make a node version default
npm i <package>Install a package
npm u <package>Update the package
npm rm <package>Remove a package
npm auditScan and list all the vulnerabilities in the package
npm audit fixFix found vulnerabilities
npm editEdit an installed package
npm publishPublish a package
npm rebuild- Rebuild a package
- This command runs the npm build command on the matched folders