cannot read property 'apply' of undefined gulp
Asked Answered
L

8

36

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

Leatherjacket answered 2/8, 2016 at 12:7 Comment(0)
E
93

Try to reinstall gulp-cli :

npm install -g gulp-cli
Echinoderm answered 10/8, 2016 at 7:6 Comment(2)
As mentioned by @ofribt on his answer, after reinstall open new terminal window and retry there.Contralto
I had to add --force at the end to get this working. Thanks a lot.Gish
P
21
npm install -g gulp-cli

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

Petersen answered 29/5, 2019 at 15:27 Comment(0)
B
5

Upgrade to 4.0 like this:

npm install --save-dev github:gulpjs/gulp#4.0 
Banebrudge answered 7/9, 2016 at 17:23 Comment(0)
A
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 
Aldrich answered 17/9, 2018 at 8:7 Comment(1)
The above code uninstalls gulp-cli globally, while your explanation recommends uninstalling it locally. Am I mistaken in seeing this inconsistency?Seligmann
W
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.

Wysocki answered 8/12, 2018 at 10:14 Comment(0)
T
1

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 :)

Ticklish answered 16/4, 2019 at 9:59 Comment(0)
R
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 [email protected] reverted things back to normal.

Renell answered 12/2, 2019 at 18:14 Comment(0)
V
0

Reinstall gulp and gulp-cli, to install the last version.

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

npm install -g gulp-cli
npm install -g gulp

And then, close the terminal and open new.

*This command no longer works: npm install --save-dev github:gulpjs/gulp#4.0

Valdez answered 29/7, 2021 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.