Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp - throw err cannot find module 'q'

I was to trying to setup Jekyll with Gulp but when I run gulp it gives me the following error:

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)

I tried going to C:\Users\Admin\jekyll-gulp-sass-browser-sync-master\node_modules\gulp\node_modules\interpret\index.js and made these changes:

var q = require('q');

to

var q = require('Q');

I ran npm install -g but still nothing. Anyone knows why I am getting this?

like image 654
Hassan Yousuf Avatar asked Oct 27 '15 18:10

Hassan Yousuf


1 Answers

Look at npm help section on install command (by typing npm help install in your terminal).

Here is what you are doing:

  • 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.

Here is what you want to do:

  • 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.

By typing npm install -g you are installing your current package context as a global package which has nothing to do with your current problem. The error Cannot find module 'q' means that q module is not installed.

To solve it type: npm install q which will install q module locally in your project directory.

like image 180
ezpn Avatar answered Oct 19 '22 14:10

ezpn