Gulp - 抛出错误找不到模块 'q'

Gulp - throw err cannot find module 'q'

我试图用 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 模块。