What is the difference between --save and --save-dev in npm install?

I am trying to understand when and where to use these tags, I understand that one is for dev dependencies and the other is for project dependencies, but when I use it for a live project, I do not find the difference. I am looking for a method that will throw an error for the wrong type of installation. is there any way to do this?

+4
source share
2 answers

dependencies- The modules that your project depends on devDependenciesare the modules that you use to develop your project. You can read the detailed description on npmjs website :

- , , , , .

devDependencies.

: request, concat-stream, object.assign, through2.

devDependencies: mocha, tape, eslint, grunt, browserify.

, , . devDependencies ( , task runner...), , - npm install . , .

. , foo, bar, baz quux . foo - baz, bar - devDependency baz, baz quux.

#/$ cd baz
#/baz$ cat package.json
{
  "name": "baz",
  "version": "0.0.0",
  "dependencies": {
    "foo": "../foo"
  },
  "devDependencies": {
    "bar": "../bar"
  }
}
#/baz$ npm install
baz@0.0.0 /tmp/tmpdir/g6jBr9/baz
β”œβ”€β”€ bar@0.0.0
└── foo@0.0.0

, devDependencies.

baz quux:

#/$ cd quux
#/quux$ cat package.json
{
  "name": "quux",
  "version": "0.0.0",
  "dependencies": {
    "baz": "../baz"
  }
}
#/quux$ npm install
#/quux$ npm ls
quux@0.0.0 /tmp/tmpdir/g6jBr9/quux
└─┬ baz@0.0.0
  └── foo@0.0.0

, foo , bar . , - (.. ), devDependencies, .

+11

npm install devDependencies, . /, devDependencies . npm help install:

With the --production flag (or when the NODE_ENV environment variable
       is set to production), npm will not install modules listed in
       devDependencies.

, --save-dev devDependencies, - , . DevDependencies , .

, devDependencies. , . , . , , , .

+3

Source: https://habr.com/ru/post/1614316/


All Articles