Issues with ionic: Error: Cannot find module '

2019-06-21 12:52发布

问题:

I've got some issues with trying to run gulp with Ionic.

The error message that pops up is this:

Error: Cannot find module 'gulp-util'

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) at Object. (/Users/emilymacleod/Desktop/myApp/gulpfile.js:2:13) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

I tried installing sass and gulp locally in the myApp folder as well as globally and no dice.

Thoughts?

回答1:

Kind of a long shot, but gulp-util is a separated module. You should install it locally:

npm install gulp gulp-util --save-dev

and require it in your code:

var gutil = require('gulp-util');


回答2:

I'm having the problem of cannot find gulp-util even after doing the procedure at the end of this. I can see it's added to the modules and the package.json, but that require statement seems to have an error. It doesn't seem to be working.

The PROCEDURE

npm install gulp gulp-util --save-dev and require it in your code: var gutil = require('gulp-util');



回答3:

I had similar issue with gulp-sass. Error message was:
Uh oh! Looks like you're missing a module in your gulpfile: Cannot find module 'gulp-sass'

Do you need to run npm install?

Resolved by executing the following:

  • npm -g install npm
  • npm install gulp-sass

Hope this help.



标签: gulp ionic