This document provides a quick reference guide for the most commonly used Node.js and npm commands.
node -v
Displays the installed Node.js version.
npm -v
Displays the installed npm version.
npm init
Starts a guided process to create a new Node.js project and generates a package.json
file.
npm install <package-name>
Installs a Node.js package. For example, npm install express
installs the Express.js library.
npm install <package-name> --save
Adds a package to your project's package.json
file as a dependency.
npm uninstall <package-name>
Removes a package from your project.
npm install -g <package-name>
Installs a package globally, making it available for all your projects.
npm update
Updates the dependencies in your project.
npm outdated
Checks if packages in your project are outdated.
node <file-name.js>
Runs a Node.js application.
npm publish
Used to publish your own package on npm.
npm unpublish <package-name> --force
Used to delete your package from npm.