Reputation: 33
okay i've been spending over a day to solve this gulp issue, i literally tried everything by run npm install
after deleting node_modules or anything i find, but when i tried to run gulp
or anything related to gulp command it always throw an error like this
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module 'gulp-util'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/usr/lib/nodejs/gulp/bin/gulp.js:4:13)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
can someone help me? so far i've tried some of this solutions:
Can't get Gulp to run: cannot find module 'gulp-util'
Cannot find module 'gulp-util'
Issues with ionic: Error: Cannot find module 'gulp-util'
and many more
Upvotes: 2
Views: 3274
Reputation: 33
This thread is quite old, but it came up when I was looking for answers so here is my solution.
Firstly, gulp-util is deprecated since 2017, so ideally nothing should be still using it in 2020. My bad luck to find something.
I tried all the usual solutions but in the end what worked was the following. (Full details found by visiting https://www.npmjs.com/package/gulp, and following the Quick Start link to https://gulpjs.com/docs/en/getting-started/quick-start for full details).
Firstly, I undid everything I had done to try to install gulp in the first place. On Ubuntu 18.04 that included:
sudo apt uninstall gulp gulp-util
sudo npm uninstall -g gulp
sudo npm uninstall -g gulp-util
Next, check that node, npm and npx are all installed.
node --version
npm --version
npx --version
Next, install gulp cli.
sudo npm i -g gulp-cli
Finally, in an appropriate folder,
npx mkdirp my-project
cd my-project
npm init
Mostly I just hit enter for every question that npm asked when initializing the project. Finally, install gulp dependencies and test the gulp version.
npm i --save-dev gulp
gulp --version
This finally returned the version number, and when I went back to the project I was trying to build with gulp that also worked.
Notes:
If using Windows you won't need the sudo I included on some of the commands.
If you are using iOS, you may or may not need the sudo. You can try without sudo and if you get permission errors try again with.
The instruction to use apt applies to Ubuntu and similar flavors of Linux to elevate privileges.
Hope this helps someone.
Upvotes: 2