Anjan Dutta
What is the difference between npm install --save and --save-dev
What is the difference between npm install --save and --save-dev
When we run the npm install package_name
command, then the package name is added in the package.json file as a dependency.
The --save
specifies that the package is required at production or development.
That means, it is a required package regardless of the environment.
Since the npm v5.0.0 we do not need to specify --save
explicitly.
The package is added under the "dependencies"
section by default.
Now, if you take a closer look at the package.json
file, then you will notice a "devDependencies"
section.
The --save-dev
option tells the installer to install the package as development only dependency.
And, the package will be added under the "devDependencies"
section.
For example, code linters are installed as a dev dependency.