gulp运行错误gulpInst.start. apply(gulpInst, toRun)

原因多种,一般是gulp cligulp版本不兼容或根本没装gulp cli

查看版本:

$ gulp -v
[14:20:53] CLI version 3.9.1
[14:20:53] Local version 4.0.2

不兼容不是因为版本号不一致,而是内容不匹配,所以不要只看版本号。(上面这组已证不兼容……)

网上最多说法是执行下面命令,没错就是全局安装下 gulp cli:

$ npm i -g gulp-cli

如果之前已安装gulp cli会报类似错误,有冲突:

npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/gulp-cli/bin/gulp.js
npm ERR! dest /usr/local/bin/gulp
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/gulp-cli/bin/gulp.js' -> '/usr/local/bin/gulp'
npm ERR! File exists: /usr/local/bin/gulp
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../../../lib/node_modules/gulp-cli/gulp.1
npm ERR! dest /usr/local/share/man/man1/gulp.1
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../../../lib/node_modules/gulp-cli/gulp.1' -> '/usr/local/share/man/man1/gulp.1'
npm ERR! File exists: /usr/local/share/man/man1/gulp.1
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

其实问题和解决方法很明显,照做就行。
删除已有的版本软链接,然后再安装,具体路径以实际环境为准:

$ sudo rm /usr/local/bin/gulp
$ sudo rm /usr/local/share/man/man1/gulp.1

最后

$ gulp -v
CLI version: 2.3.0
Local version: 4.0.2

另外,运行有类似报错,多是因为gulpnodejs版本不兼容。如果项目牵连不多,最简单办法是把各自版本都升至最新吧。

primordials is not defined

nodejs命令行报错解决方法很多就在提示信息中,多分析,避免舍近求远,别动不动就去各种搜索。