npm gulp依赖关系丢失,即使在运行npm install之后 [英] npm Gulp dependencies missing, even after running npm install
问题描述
我有一个使用Gulp的项目。我将我的项目部署到我的Ubuntu服务器上,现在想编译资产(这是我现在所有的gulp文件所做的)。安装了Node和npm后,我从项目的根目录运行 npm install
来安装依赖关系。 package.json的内容如下:
...},
devDependencies:{
bower:> = 1.3.12,
gulp:^ 3.8.10,
gulp-concat:^ 2.4.3,
gulp-less:^ 2.0.1,
gulp-minify-css:^ 0.4.3,
gulp-notify:^ 2.2.0,
gulp-rename:^ 1.2.0,
gulp-uglify:^ 1.1.0
} ...
然后检查项目根目录中的 node_modules
文件夹,我可以看到每个依赖项的目录表明他们已经安装。然而,当我运行 gulp
时,我得到如下所示的npm错误:
错误:无法在Function.Module._resolveFilename(module.js:338:15)处找到模块'through2'
在Function.Module._load(module.js:280:25)处
在Module.require(module.js:364:17)
at require(module.js:380:17)
这些似乎是我项目依赖关系的依赖项(因为它们没有在我的gulp文件中引用),但为什么没有npm安装它们?
我可以在出现错误时手动安装每个错误,但是接下来我们会得到另一个类似的错误,以解决下一个缺失的依赖关系。
我该如何解决这个问题?
解决方案是删除 node_modules
文件夹并重新运行 npm install
。
看起来初始安装由于某种原因部分失败。
I have a project that uses Gulp. I deployed my project onto my Ubuntu server and now want to compile the assets (which is all my gulpfile does at the moment). Having installed Node and npm I run npm install
from my project's root to install the dependencies. The package.json reads as follows:
...},
"devDependencies": {
"bower": ">=1.3.12",
"gulp": "^3.8.10",
"gulp-concat": "^2.4.3",
"gulp-less": "^2.0.1",
"gulp-minify-css": "^0.4.3",
"gulp-notify": "^2.2.0",
"gulp-rename": "^1.2.0",
"gulp-uglify": "^1.1.0"
}...
Upon then inspecting the node_modules
folder in my project root I can see directories for each of the dependencies indicating they were installed. However when I run gulp
I get npm errors such as the below:
Error: Cannot find module 'through2'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
These seem to be dependencies of the my project's dependencies (as they are not referenced in my gulpfile), but why hasn't npm installed them?
I can manually install each one as the error arises but I then get another similar error for the next missing dependency.
How can I solve this?
The solution was to delete the node_modules
folder and rerun npm install
.
It looks like the initial install failed partially for some reason.
这篇关于npm gulp依赖关系丢失,即使在运行npm install之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!