为什么需要 npm --save-dev [英] Why need npm --save-dev

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

问题描述

在npm安装包时,为什么要在最后加上--save-dev?

When installing packages in npm, why do we need to add --save-dev at the end?

示例:

npm install gulp-angular-templatecache --save-dev

来自在线文档(https://docs.npmjs.com/cli/install),它说包将出现在您的 devDependencies 中."那什么意识?这是否意味着,如果我不放置 --save-dev 它将安装在不同的目录中?

From the documentation online (https://docs.npmjs.com/cli/install), it says "package will appear in your devDependencies." What is that mean? Is that mean, if I don't put --save-dev it will install on different directory?

推荐答案

package.json 文件中,会自动添加 gulp-angular-templatecache 模块到JSON 中的 devDependencies 对象,像平常一样在 node_modules 下的应用程序本地安装后.唯一的区别是它编辑 package.json 文件以记住 devDependency.无论哪种方式,它都安装在相同的位置.所以在运行之后,你的 package.json 现在看起来像这样:

In the package.json file, it will automatically add the gulp-angular-templatecache module to the devDependencies object within the JSON after installing it locally in your application under node_modules like normal. The only difference is the fact that it edits the package.json file to remember that devDependency. It installs in the same location either way. So after running that, your package.json will look like this as of now:

{
  ...
  "devDependencies": {
    ...
    "gulp-angular-templatecache": "^1.5.0"
  },
  ...
}

这篇关于为什么需要 npm --save-dev的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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