This npm commands cheat sheet lists the Node.js package manager commands you use most — installing, removing and updating packages, and running scripts.
| Command | What it does |
|---|---|
| npm init | Create package.json |
| npm init -y | Create with defaults |
| npm install | Install all dependencies |
| npm install <pkg> | Add a package |
| npm install -D <pkg> | Add a dev dependency |
| npm install -g <pkg> | Install globally |
| npm uninstall <pkg> | Remove a package |
| npm update | Update packages |
| npm run <script> | Run a package.json script |
| npm start | Run the start script |
| npm test | Run tests |
| npm ls | List installed packages |
| npx <pkg> | Run a package without installing |