缺少 npm Gulp 依赖项,即使在运行 npm install 之后也是如此 [英] npm Gulp dependencies missing, even after running npm install

查看:48
本文介绍了缺少 npm Gulp 依赖项,即使在运行 npm install 之后也是如此的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Gulp 的项目.我将我的项目部署到我的 Ubuntu 服务器上,现在想要编译资产(这是我的 gulpfile 目前所做的一切).安装 Node 和 npm 后,我从项目的根目录运行 npm install 来安装依赖项.package.json 内容如下:

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"
  }...

然后检查我的项目根目录中的 node_modules 文件夹,我可以看到每个依赖项的目录,表明它们已安装.但是,当我运行 gulp 时,会出现如下 npm 错误:

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)

这些似乎是我项目依赖项的依赖项(因为我的 gulpfile 中没有引用它们),但是为什么 npm 没有安装它们?

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?

推荐答案

解决方法是删除node_modules文件夹,重新运行npm install.

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屋!

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