gulp无法运行 - Cannot read property 'apply' of undefined

今天自己新建了一个项目,准备使用gulp做自动化开发。结果安装好gulp之后,无法正常启动….

报错信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
F:\...\project>gulp
[08:05:18] Using gulpfile F:\...\project\gulpfile.js
C:\Users\flyfi\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\flyfi\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

其实问题很简单,因为全局的gulp和项目中的gulp版本不同导致的。
查看版本:

1
2
3
F:\...\project>gulp -v
[08:06:47] CLI version 3.9.1
[08:06:47] Local version 4.0.0

删除项目的gulp,重新安装3.9.1的即可。