JavaScript npm Basics Installing Packages with npm Managing Dependencies in the package.json File

Craig Curtis
Craig Curtis
19,985 Points

Difference between npm install something vs. npm install something --save vs. npm install something --save-dev

I've tried both --save and --save-dev npm installing, but in package.json, I only see something in dependencies rather than dev dependencies. So when do we use each of these?

  1. npm install something
  2. npm install something --save
  3. npm install something --save-dev

1 Answer

Chyno Deluxe
Chyno Deluxe
16,921 Points

Hi Craig,

The differences between all three are as follow.

  1. will install the npm package to your node_modules folder and not be added to the package.json
  2. --save - package(s) required by the application to run
  3. --save-dev - package(s) required for development purpose.
Craig Curtis
Craig Curtis
19,985 Points

Ok it makes sense. I was just having an error that threw me off -- my index.html wasn't being updated with --save for some reason the first time. Thank you!

I don't think this is correct any longer. The latest version of npm allows you to do npm install <package> and it does show up in package.json, without needing --save. You may need to update your comment.