npm install 不会安装 devDependencies [英] npm install won't install devDependencies

查看:92
本文介绍了npm install 不会安装 devDependencies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,在 Windows 上,当我运行 npm install 时,它不会安装 devDependencies.AFAIK它应该.如果我运行 npm install --dev devDependencies 安装.我不明白为什么 npm install 也不安装 devDependencies,而是只安装依赖项.可能是什么原因?我该如何解决?

On windows for some reason when I run npm install it won't install devDependencies. AFAIK it should. If I run npm install --dev devDependencies are installed. I don't understand why npm install doesn't install devDependencies too, but installs only dependencies. What could be the reason? How can I fix it?

也许我的 package.json 有问题?如果有帮助,请在下面列出:

Maybe something is wrong with my package.json? It is listed below if it may be helpful:

{
  "name": "try-brunch",
  "version": "0.1.0",
  "private": "true",
  "devDependencies": {
    "brunch": "^2.0.4",
    "cssnano-brunch": "^1.1.5",
    "javascript-brunch": "^1.8.0",
    "sass-brunch": "^1.9.2",
    "uglify-js-brunch": "^1.7.8"
  },
  "dependencies": {
    "jquery": "^2.1.4"
  }
}

推荐答案

检查 NPM 文档以了解 安装

Check the NPM docs for install

使用 --production 标志(或当 NODE_ENV 环境变量设置为生产时),npm 将不会安装 devDependencies 中列出的模块."

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies."

--only={prod[uction]|dev[elopment]} 参数将导致只安装 devDependencies 或只安装非 devDependencies,而不管 NODE_ENV."

The --only={prod[uction]|dev[elopment]} argument will cause either only devDependencies or only non-devDependencies to be installed regardless of the NODE_ENV."

你试过了吗

npm install --only=dev

如果您担心您的 package.json 可能不正确,最好的做法是这样做.创建一个新文件夹,然后运行:

If you are worried that your package.json might be incorrect, best thing to do is this. Create a new folder, and run:

npm init --yes

那么:

npm install --save-dev brunch@^2.0.4
npm install --save-dev cssnano-brunch@^1.1.5
npm install --save-dev javascript-brunch@^1.8.0
npm install --save-dev sass-brunch@^1.9.2
npm install --save-dev uglify-js-brunch@^1.7.8
npm install jquery@^2.1.4 --save

你应该很高兴去吧!否则,将继续发布其他选项.

And you should be good to go! Otherwise, will keep posting other options.

检查您的 npm 配置:

Check your npm configuration:

npm config list

npm 从命令行、环境变量和 npmrc 文件中获取其配置设置.因此,请检查环境变量和 npmrc 文件.

npm gets its config settings from the command line, environment variables, and npmrc files. So check environment variables, and the npmrc file.

仍然失败?

好的,创建一个新文件夹,最好是文件系统上的其他位置.IE.不在同一个文件夹层次结构中.例如,C:myNewFolder - 越接近基本 C: 驱动器越好.

Ok, create a new folder, ideally somewhere else on your filesystem. ie. not in same folder hierarchy. For instance, C:myNewFolder - the closer to the base C: drive the better.

然后运行:

npm init --yes

现在运行:

npm install underscore --save

最后:

npm install mocha --save-dev

一切都按预期进行吗?

我想要做的是了解您的问题是全局性的,还是先前文件夹和依赖项的本地问题.

What I am trying to do is understand whether your problem is global, or something local to the previous folder and dependencies.

这篇关于npm install 不会安装 devDependencies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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