我试图用 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/