npm install/uninstall
npm install downloads a package into your project and npm uninstall removes it again.
In this page:
Syntax
npm install
npm install package_name
npm install package_name@version
npm uninstall package_name
npm install/uninstall
npm install with no arguments installs everything listed in package.json. npm install name adds a dependency, npm install -D name adds a dev dependency and npm install -g name installs globally. npm uninstall name removes the package and updates package.json.
Note:
Use npm ci in CI pipelines for a clean, exact install from the lock file.
Example: npm install/uninstall
$ npm install express
added 64 packages in 3s
$ npm install -D nodemon
$ npm uninstall nodemon
removed 29 packages in 1s
$ npm ci
⚠️ Run this in your own terminal or Node.js environment.
Related Topics
Common Mistakes
- Installing globally when a local install is enough
- Forgetting to save the dependency
- Deleting node_modules but not reinstalling
Chapter Summary
- npm install adds packages
- -D saves as a dev dependency
- npm uninstall removes
- npm ci gives clean reproducible installs
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: