gulp-cli fails if local gulp is 4.0

Within my project’s package.json I have:

json
"dependencies": {
  "gulp": "git+https://github.com/gulpjs/gulp.git#4.0"
}

If I globally install stable gulp (3.X) and run gulp it fails (known issue, ok). But if I globally install gulp-cli it also fails:

bash
$ gulp
[15:59:34] Using gulpfile ~/src/XXX/gulpfile.js

/Users/xxxxxx/.npm-packages/lib/node_modules/gulp-cli/index.js:133
    gulpInst.start.apply(gulpInst, toRun);
                   ^
TypeError: Cannot call method 'apply' of undefined
    at /Users/xxxxxx/.npm-packages/lib/node_modules/gulp-cli/index.js:133:20
    at process._tickDomainCallback (node.js:463:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:906:3

I fail to understand the purpose of gulp-cli if it fails in this scenario. Do I miss something?

5 thoughts on “gulp-cli fails if local gulp is 4.0

  1. If anyone’s testing gulp 4 in a project and doesn’t want to install gulp globally, you can reference the local gulp 4.0 with $(npm bin)/gulp.

  2. I’m new to gulp.

    I’m getting the similar error when i run gulp command

    package.json

    `json
    "dependencies": {
         "gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb",
    }`
    
    bash
    /usr/local/lib/node_modules/gulp/bin/gulp.js:129
        gulpInst.start.apply(gulpInst, toRun);
                      ^
    
    TypeError: Cannot read property 'apply' of undefined
        at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:19
        at nextTickCallbackWith0Args (node.js:420:9)
        at process._tickCallback (node.js:349:13)
        at Function.Module.runMain (module.js:443:11)
        at startup (node.js:139:18)
        at node.js:968:3
    
    

    Even I tried running npm install -g “#4.0″ as @heikki said

    My present version is
    CLI version 3.9.1
    Local version 4.0.0-alpha.2

  3. @xzegga yep I resolved it , it’s working.

    Bring back your CLI version to 1.2.2 it will support gulp 4, and will solve your problem.

    to install gulp-cli 1.2.2 run sudo npm install gulp-cli@1.2.2 -g
    and to install gulp local run npm install 'gulpjs/gulp.git#4.0' --save-dev

    when you run gulp -v command

    you should get
    [11:38:36] CLI version 1.2.2
    [11:38:36] Local version 4.0.0-alpha.2