npm install save by default

It happened too many times that I forgot to add --save when installing node modules. Is there a way to append this option by default? So that whenever I type npm install <package> the package is added to dependencies in package.json.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

From npm5 , npm will save by default .

Solution 2

I found out that npm has configuration flags. Setting save=true does exactly what I need. You can add it to .npmrc file (in user’s home directory) or invoke a command:

npm config set save=true

Solution 3


make an alias inside ~/.bash_profile

alias npmi="npm install --save"
//shorter version
alias npmi="npm i -S"

then just type, so that it will automatically save it to package json

npmi mongoose


same thing, make alias, read more here

doskey npmi=npm i -S $*

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply