npm install --save和npm install --save-dev之间的区别 [英] Difference between npm install --save and npm install --save-dev

查看:80
本文介绍了npm install --save和npm install --save-dev之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我知道使用 npm install -g 我们可以全局安装节点模块/软件包,但是我不确定-save -保存开发

Guys I know that using npm install -g we can install the node modules/packages globally, but I am not sure about the options --save and --save-dev

我已经对其进行了Google搜索,但仍不清楚.请分享您的想法.

I have Googled it but still not clear about it. Please share your thoughts.

推荐答案

-save 将第三方程序包添加到程序包的依赖项中.每当有人运行 npm install yourPackage 时,它将与软件包一起安装.

--save adds the third-party package to the package's dependencies. It will be installed together with the package whenever someone runs npm install yourPackage.

-save-dev 将第三方程序包添加到程序包的开发依赖项中.当有人安装您的软件包时,将不会安装它.通常只有在有人克隆您的源存储库并在其中运行 npm install 的情况下,才安装它.

--save-dev adds the third-party package to the package's development dependencies. It won't be installed when someone installs your package. It's typically only installed if someone clones your source repository and runs npm install in it.

Dev依赖项是仅开发软件包所需的那些依赖项.其中可能包括测试运行程序,编译器,打包程序等.

Dev dependencies, as the same suggests, are those dependencies that are only needed for developing the package. That can include test runners, compilers, packagers, etc.

这两种依赖关系类型都存储在程序包的 package.json 文件中.-save 添加到 dependencies -save-dev 添加到 devDependencies .摘自文档:

Both types of dependencies are stored in the package's package.json file. --save adds to dependencies, --save-dev adds to devDependencies. From the documentation:

devDependencies

如果某人打算在程序中下载和使用您的模块,那么他们可能不希望或不需要下载并构建您使用的外部测试或文档框架.

If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.

在这种情况下,最好将这些其他项映射到devDependencies对象中.

In this case, it's best to map these additional items in a devDependencies object.

这些内容将在从软件包根目录执行npm link或npm install时安装,并且可以像任何其他npm配置参数一样进行管理.有关该主题的更多信息,请参见npm-config(7).

These things will be installed when doing npm link or npm install from the root of a package, and can be managed like any other npm configuration param. See npm-config(7) for more on the topic.

对于不是特定于平台的构建步骤(例如,将CoffeeScript或其他语言编译为JavaScript),请使用预发布脚本执行此操作,然后将所需的软件包设置为devDependency.

For build steps that are not platform-specific, such as compiling CoffeeScript or other languages to JavaScript, use the prepublish script to do this, and make the required package a devDependency.

npm 5.0.0 开始,已安装的模块将作为依赖项添加默认情况下,因此不再需要--save选项.

As of npm 5.0.0 the installed modules are added as a dependency by default, so the --save option is no longer needed.

这篇关于npm install --save和npm install --save-dev之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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