npm install的--save选项是什么? [英] What is the --save option for npm install?
问题描述
我看到了一些命令所在的教程:
I saw some tutorial where the command was:
npm install --save
--save
选项是什么意思?
无法在Google上找到答案.
Not able to find the answer on Google.
推荐答案
更新npm 5:
从 npm 5.0.0 开始,默认情况下已安装的模块作为依赖项添加,因此不再需要--save
选项.其他保存选项仍然存在,并在npm install
的文档中列出.
As of npm 5.0.0, installed modules are added as a dependency by default, so the --save
option is no longer needed. The other save options still exist and are listed in the documentation for npm install
.
原始答案:
在版本5之前,NPM默认情况下只是在node_modules
下安装了一个软件包.当您尝试为应用程序/模块安装依赖项时,需要先安装它们,然后将它们(以及适当的版本号)添加到package.json
的dependencies
部分.
Before version 5, NPM simply installed a package under node_modules
by default. When you were trying to install dependencies for your app/module, you would need to first install them, and then add them (along with the appropriate version number) to the dependencies
section of your package.json
.
--save
选项指示NPM将软件包自动包含在package.json
的dependencies
部分中,从而为您节省了额外的步骤.
The --save
option instructed NPM to include the package inside of the dependencies
section of your package.json
automatically, thus saving you an additional step.
此外,还有互补选项--save-dev
和--save-optional
,它们分别将软件包保存在devDependencies
和optionalDependencies
下.当安装仅开发包,例如grunt
或测试库时,这很有用.
In addition, there are the complementary options --save-dev
and --save-optional
which save the package under devDependencies
and optionalDependencies
, respectively. This is useful when installing development-only packages, like grunt
or your testing library.
这篇关于npm install的--save选项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!