← Back to Node.js Course | Chapter 3: npm & Packages | Lesson 2 of 7

npm install/uninstall

npm install downloads a package into your project and npm uninstall removes it again.

In this page:

  1. npm install/uninstall
Syntax
javascript
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

bash
$ 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
  1. Installing globally when a local install is enough
  2. Forgetting to save the dependency
  3. 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:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.