What's the difference between these What does --save do in the command
$ npm install express --save
$ npm install express
What's the difference between these What does --save do in the command
$ npm install express --save
$ npm install express
The save flag adds express
to your package.json
file. This file is used to store information about your project, such as its dependencies.
By doing npm install express --save
, your project officially records that you have express installed and that your project needs it to run. Now lets say you sent your friend your source code, they can just run npm install
and it will check package.json
, recognize you installed express as a dependency, and it'll install it for them.
When installing a module using npm
the --save
option saves the module name and version to the package.json
file. It is the default and the module will be saved event without the parameter. Having the modules listed in the package.json
file allows you to install all the needed modules for a project using npm install
It should be mentioned that this saves a runtime dependency. If there is a module which is only used during development (e.g. nodemon
) you install it using --save-dev
so it is saved as a development dependency. Check the link above for all the npm
options