npm install save by default

╄→гoц情女王★ 提交于 2019-12-06 00:40:40

问题


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.


回答1:


From npm5 , npm will save by default . https://github.com/npm/npm/issues/5108




回答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



回答3:


Mac/Linux

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

Windows

same thing, make alias, read more here https://superuser.com/a/49194

doskey npmi=npm i -S $*


来源:https://stackoverflow.com/questions/37852695/npm-install-save-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!