9

I have recently come across one of these statements in a node project that I am currently working on that we use to install node modules locally

npm install -d --save

Can somebody please tell me what it means as earlier we used to use simply npm install

I want to know the difference between the two

Nav
  • 10,304
  • 20
  • 56
  • 83
  • 1
    http://stackoverflow.com/questions/19578796/what-is-the-save-option-for-npm-install and http://stackoverflow.com/questions/8783230/what-is-the-d-in-npm-d-install – srquinn Mar 06 '14 at 19:09
  • Also, there's always the [documentation](https://www.npmjs.org/doc/misc/npm-config.html). – ajp15243 Mar 06 '14 at 19:09
  • i tried googling didn't exactly find it..anyways thanks guys and jibsales can u please post your answer as an actual answer so that i can close this question :) – Nav Mar 06 '14 at 19:12
  • @jibsales dude can you please post your comment as an answer so that I can close this question – Nav Mar 06 '14 at 19:16
  • @ajp15243 If only that were true! The documentation is now missing. – Steve Pitchers Jun 01 '18 at 12:37
  • Docs page has changed: https://docs.npmjs.com/cli/v7/commands/npm-install – Ricardo Mar 24 '21 at 00:44

2 Answers2

8

From http://npmjs.org/doc/misc/npm-config.html:

The following shorthands are parsed on the command-line: -d: --loglevel info

From https://www.npmjs.org/doc/install.html

--save: Package will appear in your dependencies.

Steve Jansen
  • 9,398
  • 2
  • 29
  • 34
5

It adds it to your dependencies in your packages.json

For example, I just did

npm install async --save

It added this to my packages.json

"dependencies": {
  "async": "~0.2.10",

Before you do that however, make sure you create your packages.json by running

npm init

By adding packages to source control (but not the node_modules it lays down locally), when others consume your solution, when they do 'npm install' after pulling your solution, it will pull those dependencies - you don't have to distribute.

https://www.npmjs.org/doc/cli/npm-install.html

bryanmac
  • 38,941
  • 11
  • 91
  • 99