npm install的--save选项是什么? [英] What is the --save option for npm install?

查看:1192
本文介绍了npm install的--save选项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一些命令所在的教程:

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.jsondependencies部分.

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.jsondependencies部分中,从而为您节省了额外的步骤.

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,它们分别将软件包保存在devDependenciesoptionalDependencies下.当安装仅开发包,例如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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆