Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.