node.js - Gulp - throw err 找不到模块 'q'

标签 node.js npm gulp jekyll

我试图用 Gulp 设置 Jekyll,但是当我运行 gulp 时,它给了我以下错误:

C:\Users\Admin\jekyll-gulp-sass-browser-sync-master>gulp
module.js:339
    throw err;
    ^

Error: Cannot find module 'q'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (C:\Users\Admin\jekyll-gulp-sass-browser-sync-master\node_modules\browser-sync\node_modules\portscanner-plus\lib\index.js:3:9)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

我尝试转到 C:\Users\Admin\jekyll-gulp-sass-browser-sync-master\node_modules\gulp\node_modules\interpret\index.js 并进行了以下更改:

var q = require('q');

var q = require('Q');

我运行了 npm install -g 但仍然没有。任何人都知道为什么我得到这个?

最佳答案

查看有关安装命令的 npm 帮助部分(通过在终端中键入 npm help install)。

这是你正在做的:

  • npm install (in package directory, no arguments):

    Install the dependencies in the local node_modules folder. In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package. By default, npm install will install all modules listed as dependencies. With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.

这是你想要做的:

  • npm install [@/] [--save|--save-dev|--save-optional]:

    Do a @ install, where is the "tag" config. (See npm help 7 npm-config.) In most cases, this will install the latest version of the module published on npm.

通过键入 npm install -g,您正在将当前包上下文安装为全局包,这与您当前的问题无关。错误 Cannot find module 'q' 表示未安装 q 模块。

要解决这个问题,请键入:npm install q 它将在您的项目目录中本地安装 q 模块。

关于node.js - Gulp - throw err 找不到模块 'q',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33375815/

相关文章:

javascript - 使用 Node.js 从 MySQL 数据库进行 Ext js 树延迟加载

node.js - NPM,从错误的URL地址下载依赖项

node.js - 在哪里安装gulp?

javascript - 访问 gulp 文件夹之外的文件

node.js - 使用 nodejs 服务器配置 browserSync

javascript - 如何在 Node js 中使数组脱离函数?

node.js - Node js strip 连接缺少requested_capability : ['card_payments' ] param from create account function

javascript - node.js/javascript 在其他数组中添加一个数组作为子数组

npm - Gulp-compass : Error: Cannot load such file --susy 中的 Susy 和断点

node.js - 在 mips Big Endian 上交叉编译 node.js 模块