Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript npm Basics (retiring) 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

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.