How to fix: npm error 'cannot find gulp-cli module' when running gulp, despite gulp-cli being installed?
Asked Answered
A

4

8

I am following this SASS tutorial by net-ninja on YouTube which recommends installing gulp with SASS. However I can't get gulp to work. As per the tutorial I created the gulpfile.js, index.html and index.css then I ran the following npm commands:

npm init
npm install gulp gulp-sass sass --save-dev

When I ran gulp, I get the error:

Error: Cannot find module 'gulp-cli'

So I ran

npm install gulp-cli --save-dev

But the error persists. As per the comments in the YouTube tutorial I also installed gulp and gulp-cli as global modules with:

npm install --global gulp gulp-cli --save-dev

but this did not change anything. Gulp-cli is in both my global modules folder and the node_modules folder within the project folder. Can anyone propose a solution please?

Similar questions here and here, but not exact and following both of them doesn't resolve the issue.

Autotype answered 4/10, 2021 at 23:14 Comment(2)
Do you run the commands from the project root / where the gulpfile is?Pullet
Yes, using the terminal in VScodeAutotype
A
3

In my case -force did it

npm install --global gulp-cli -force
Aribold answered 20/5, 2022 at 10:18 Comment(0)
M
2

Same problem here, on other installations (WSL2 ubuntu 20.04) it worked with no problems, this time around it did not (on dedicated ubuntu 20.04 dev server).

Anyway, followed the gulp get started Gulp website While I was in the root directory and after running npm install --global gulp-cli everything worked fine

Mamey answered 1/2, 2022 at 20:45 Comment(0)
B
2

I ran into the same problem with the installation and then I had to go to the official gulp documentation . What I noticed was that;

  1. running gulp and getting Error: Cannot find module 'gulp-cli' was becuase gulp-cli wasn't previously installed on my local machine.
  2. When you try to install gulp-cli after this error message, it still doesn't sync and you keep getting gulp-cli module not found.

To fix this:

  1. I had to trace all the gulp folders in my installation directory in ubuntu I found them by running which gulp on my terminal
  2. I deleted all of those files, so that when I run which gulp it wouldn't find any installation of gulp
  3. Next, I followed the installation steps described in the gulp official documentation - https://gulpjs.com/docs/en/getting-started/quick-start/
  4. Now when I ran npm install --save-dev gulp in my project directory and started gulp by running gulp, the issues where fixed.
Bingen answered 26/8, 2022 at 22:4 Comment(0)
D
0

You could use yarn to install gulp instead:

sudo yarn add gulp --location=global
Donate answered 2/6, 2022 at 16:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.