31

I am trying to use the ng-factory generator to scaffold a new project to build an angularjs component. After the project has been created with the yo ng-factory command, I tried to run it using the gulp serve task but found the following error:

c:\projects\bywebclient>gulp serve
[11:20:51] Loading C:\projects\bywebclient\gulp_tasks\browsersync.js
[11:20:52] Loading C:\projects\bywebclient\gulp_tasks\karma.js
[11:20:57] Loading C:\projects\bywebclient\gulp_tasks\misc.js
[11:20:57] Loading C:\projects\bywebclient\gulp_tasks\webpack.js
[11:21:07] Using gulpfile c:\projects\bywebclient\gulpfile.js
C:\Users\ATUL KALE\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129
gulpInst.start.apply(gulpInst, toRun);

^

TypeError: Cannot read property 'apply' of undefined
at C:\Users\ATUL KALE\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129: 19

at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:577:11)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
at bootstrap_node.js:467:3

Am I missing something? I already tried to run again the npm install

Thanks, Atul Kale

atul kale
  • 311
  • 1
  • 3
  • 4

7 Answers7

84

Try to reinstall gulp-cli :

npm install -g gulp-cli
Davide Castronovo
  • 1,223
  • 8
  • 20
18
npm install -g gulp-cli

And important: after running that command, open a new terminal so it'll take effect.

ofirbt
  • 1,728
  • 7
  • 25
  • 39
5

Upgrade to 4.0 like this:

npm install --save-dev github:gulpjs/gulp#4.0 
Shaun Luttin
  • 107,550
  • 65
  • 332
  • 414
3

Uninstall the global gulp installation and local gulp-cli installation. While keeping global gulp-cli and local gulp packages.

npm uninstall -g gulp
npm uninstall -g gulp-cli

npm install -g gulp-cli
npm install --save-dev github:gulpjs/gulp#4.0 
Dmitri Algazin
  • 3,017
  • 21
  • 25
dev8516
  • 59
  • 4
  • The above code uninstalls `gulp-cli` **globally**, while your explanation recommends uninstalling it locally. Am I mistaken in seeing this inconsistency? – phantomraa Sep 17 '19 at 22:37
2

I get below error everytime i run

npm install gulp -g --save

TypeError: Cannot read property 'apply' of undefined

at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)

I tried:

npm i -g gulp-cli

and it works for me.

If again i run

npm install gulp -g --save

the above error returns. I noted when i first installed Gulp it was saved in my package.json but now it's absent.

0

In my case, I had an automated script which was doing npm install gulp (...) and until v3.9x it was fine.

After some time, that naive install would pick v4.0.0, which breaks my CI.

Changing the script to do npm install gulp@3.9.1 reverted things back to normal.

0

I tried uninstalling both gulp and gulp-cli from my machine (locally and globally), but after uninstall gulp -v, it still showed Gulp CLI 3.9.1, even in new terminal window. In the end, these are the steps that finally worked for me (seems like CLI simply got cached hard):

  1. Navigate to your project and delete node_modules folder.

  2. Run following:

npm uninstall gulp --global
npm uninstall gulp-cli --global
apt-get remove npm
apt-get remove nodejs
apt-get install nodejs
apt-get install npm
npm install --global gulp-cli
  1. Navigate to your project and run: npm install

  2. Close current terminal, open new one and check for success: gulp -v

Should say CLI version 2.1.0 (as of time of writing).

Now you can run your gulp tasks without that error :)

Starwave
  • 2,051
  • 1
  • 16
  • 22