简体   繁体   English

无法读取未定义吞咽的属性“应用”

[英]cannot read property 'apply' of undefined gulp

I am trying to use the ng-factory generator to scaffold a new project to build an angularjs component.我正在尝试使用 ng-factory 生成器来搭建一个新项目来构建一个 angularjs 组件。 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:使用 yo ng-factory 命令创建项目后,我尝试使用 gulp serve 任务运行它,但发现以下错误:

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在 C:\\Users\\ATUL KALE\\AppData\\Roaming\\npm\\node_modules\\gulp\\bin\\gulp.js:129:19

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

Am I missing something?我错过了什么吗? I already tried to run again the npm install我已经尝试再次运行 npm install

Thanks, Atul Kale谢谢,阿图尔羽衣甘蓝

尝试重新安装gulp-cli :

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

重要的是:运行该命令后,打开一个新终端使其生效。

像这样升级到4.0:

npm install --save-dev github:gulpjs/gulp#4.0 

Uninstall the global gulp installation and local gulp-cli installation.卸载全局 gulp 安装和本地 gulp-cli 安装。 While keeping global gulp-cli and local gulp packages.同时保留全局 gulp-cli 和本地 gulp 包。

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

npm install -g gulp-cli
npm install --save-dev github:gulpjs/gulp#4.0 

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.我注意到当我第一次安装 Gulp 时,它保存在我的 package.json 中,但现在它不存在了。

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.我尝试从我的机​​器(本地和全局)卸载gulpgulp-cli ,但是在卸载gulp -v ,它仍然显示Gulp CLI 3.9.1 ,即使在新的终端窗口中也是如此。 In the end, these are the steps that finally worked for me (seems like CLI simply got cached hard):最后,这些是最终对我有用的步骤(似乎 CLI 只是被硬缓存了):

  1. Navigate to your project and delete node_modules folder.导航到您的项目并删除node_modules文件夹。

  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导航到您的项目并运行: npm install

  2. Close current terminal, open new one and check for success: gulp -v关闭当前终端,打开新终端并检查是否成功: gulp -v

Should say CLI version 2.1.0 (as of time of writing).应该说CLI version 2.1.0 (截至撰写本文时)。

Now you can run your gulp tasks without that error :)现在您可以运行您的 gulp 任务而不会出现该错误:)

In my case, I had an automated script which was doing npm install gulp (...) and until v3.9x it was fine.就我而言,我有一个自动脚本,它正在执行npm install gulp (...) gulp npm install gulp (...)并且直到 v3.9x 为止都很好。

After some time, that naive install would pick v4.0.0, which breaks my CI.一段时间后,这个天真的安装会选择 v4.0.0,这破坏了我的 CI。

Changing the script to do npm install gulp@3.9.1 reverted things back to normal.更改脚本以执行npm install gulp@3.9.1事情恢复正常。

Reinstall gulp and gulp-cli, to install the last version.重新安装 gulp 和 gulp-cli,以安装最新版本。

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 *此命令不再有效: npm install --save-dev github:gulpjs/gulp#4.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM