19
13

More than 5 years have passed since last update.

gulp4使おうとした時にTypeError: Cannot read property 'apply' of undefined でエラーになっていた原因

Posted at

エラーは以下

TypeError: Cannot read property 'apply' of undefined

gulpのバージョンを確認すると、ローカルとグローバル(CLI)のバージョンが違っていたのでこれが原因のよう。

$ gulp -v
[03:27:01] Requiring external module babel-core/register
[03:27:01] CLI version 3.9.0
[03:27:01] Local version 4.0.0-alpha.2

そういえばgulpはグローバルとローカル両方使われるんだった。
http://nakajmg.github.io/blog/2014-09-03/gulp-structure.html

(2016/01/24現在)
npmの最新が3.9.0なので、gulp4を使いたいときはオプションなしの npm install ではダメで、インストール元をgithubに向けなければならない。
以下のコマンドでgulpをアップデートする。(再インストール)

npm uninstall gulp -g
npm install gulpjs/gulp-cli#4.0 -g

バージョンがこうなっていればOK

$ gulp -v
[03:33:52] Requiring external module babel-core/register
[03:33:52] CLI version 0.4.0
[03:33:52] Local version 4.0.0-alpha.2

0.4.0 と4.0.0違うじゃん!と思ったけどこれでいいようだ。先述のエラーは解消。

19
13
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
13