Update npm 5:
(更新npm 5:)
As of npm 5.0.0 , installed modules are added as a dependency by default, so the --save
option is no longer needed.
(从npm 5.0.0开始 ,默认情况下已安装的模块作为依赖项添加,因此不再需要--save
选项。)
The other save options still exist and are listed in the documentation for npm install
. (其他保存选项仍然存在,并在npm install
的文档中列出。)
Original answer:
(原始答案:)
Before version 5, NPM simply installed a package under node_modules
by default.
(在版本5之前,默认情况下,NPM只是在node_modules
下安装了一个软件包。)
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
. (当您尝试为应用程序/模块安装依赖项时,您需要先安装它们,然后将它们(以及适当的版本号)添加到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
选项指示NPM自动将软件包包括在package.json
的dependencies
部分中,从而为您节省了额外的步骤。)
In addition, there are the complementary options --save-dev
and --save-optional
which save the package under devDependencies
and optionalDependencies
, respectively.
(此外,还有补充选项--save-dev
和--save-optional
,它们分别将软件包保存在devDependencies
和optionalDependencies
下。)
This is useful when installing development-only packages, like grunt
or your testing library. (在安装仅限开发的软件包(例如grunt
或测试库)时,这很有用。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…