0

What's the difference between these What does --save do in the command

$ npm install express --save

$ npm install express

opeolluwa
  • 96
  • 8
  • 1
    Does this answer your question? [What is the --save option for npm install?](https://stackoverflow.com/questions/19578796/what-is-the-save-option-for-npm-install) – Brettski Mar 07 '21 at 19:32

2 Answers2

2

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.

What is the --save option for npm install?

cseitz
  • 1,116
  • 4
  • 16
1

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

Brettski
  • 19,351
  • 15
  • 74
  • 97