[node.js] What is the --save option for npm install?


It won't do anything if you don't have a package.json file. Start by running npm init to create one. Then calls to npm install --save or npm install --save-dev or npm install --save-optional will update the package.json to list your dependencies.


I saw some tutorial where the command was:

npm install --save

What does the --save option mean?

Not able to find the answer on Google.

As of npm 5, it is more favorable to use --save-prod (or -P) than --save but doing the same thing, as is stated in npm install. So far, --save still works if provided.

npm install package_x --save

The given package (package_x) will be saved in package.json inside dependencies. if you add

npm install <> --save-dev

then it will be saved inside "devDependencies".

npm i (Package name) --save

Simplily, using above command we ll not need to write package name in your package.json file it ll auto add its name and dependency with version that you ll need at time when you go for production or setup another time.

npm help install

Above command ll help find out more option and correct def.shown in pic



node.js node.js   npm npm