npm install不会安装devDependencies [英] npm install won't 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文档中检查安装
使用
--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配置:
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屋!