What is the difference between:
npm install [package_name]
and:
npm install [package_name] --save
and:
By default, NPM simply installs a package under node_modules. When you're trying to install dependencies for your app/module, you would need to first install them, and then add them to the dependencies
section of your package.json
.
--save-dev
adds the third-party package to the package's development dependencies. It won't be installed when someone runs npm install
directly to install your package. It's typically only installed if someone clones your source repository first and then runs npm install
in it.
--save
adds the third-party package to the package's dependencies. It will be installed together with the package whenever someone runs npm install package
.
Dev dependencies are those dependencies that are only needed for developing the package. That can include test runners, compilers, packagers, etc.
Both types of dependencies are stored in the package's package.json
file. --save
adds to dependencies
, --save-dev
adds to devDependencies
npm install documentation can be referred here.
--
Please note that --save
is now the default option, since NPM 5. Therefore, it is not explicitly needed anymore. It is possible to run npm install
without the --save
to achieve the same result.