52

I've been using gulp-watch. The current version of gulp-watch relies on the call gulp.parrallel. This call is only available from gulp 4.

However gulp 4 is not available via the npm repo. npm info gulp dist-tags returns: { latest: '3.9.0' }.

I can see that there is a 4.0 branch within the git repo. But attempting to install it with variations on this command fails: npm install https://github.com/gulpjs/gulp#v4.0.0.

dave dave
  • 947
  • 3
  • 10
  • 15

11 Answers11

38
# Uninstall previous Gulp installation and related packages, if any
$ npm rm gulp -g
$ npm rm gulp-cli -g
$ cd [your-project-dir/]
$ npm rm gulp --save-dev
$ npm rm gulp --save
$ npm rm gulp --save-optional
$ npm cache clean # for npm < v5

# Install the latest Gulp CLI tools globally
$ npm install gulpjs/gulp-cli -g

# Install Gulp 4 into your project as dev dependency
$ npm install gulp --save-dev

# Check the versions installed. Make sure your versions are not lower than shown.
$ gulp -v
---
[10:48:35] CLI version 2.0.1
[10:48:35] Local version 4.0.0

Detail info is on this blog page: https://demisx.github.io/gulp4/2015/01/15/install-gulp4.html

demisx
  • 7,217
  • 4
  • 45
  • 43
  • 1
    How do people know that from the beginning? I'm guessing you looked it up somehow and not guessed by trial-and-error. I've seen similar for other alpha stage packages and I can't see any systematics in there. Personally, I'd like something like npm install packagename --latest or something. How did you do it? – Konrad Viltersten Nov 16 '16 at 13:39
  • @KonradViltersten Some of this came from communication with the gulp developers and the rest from the real-life experience using Gulp 4. – demisx Nov 18 '16 at 02:22
  • 2
    Darn... In other terms: "luck and black magic". At least as it feels to my ignorant self, hahaha. I'm so grateful for StackOverflow and the engaged users like yourself. – Konrad Viltersten Nov 18 '16 at 07:04
  • I think the branch part is outdated now: npm ERR! error: pathspec '4.0' did not match any file(s) known to git – Neithan Max Oct 30 '18 at 15:01
  • I have the same problem with pathspec '4.0'. Are there any solutions? – Igor Kanshyn Oct 31 '18 at 14:12
  • Looks like they've changed their repo tags. You have to go with `gulp@next` now. I've updated the installation instructions. Let me know if you find any other issues. I haven't tested these for some time now. – demisx Oct 31 '18 at 18:24
  • 4
    I guess it's changed again because `gulp@next` didn't work for me but `gulp@4.0.0` now does. – Phil Gyford Jan 22 '19 at 14:04
  • @PhilGyford Yep, looks like they finally release v4. I've updated instructions. Thanks for the heads up! – demisx Jan 22 '19 at 19:42
35

Gulp has removed the 4.0 branch from their GitHub repository, so the previous way of installing using npm install gulpjs/gulp.git#4.0 --save-dev no longer works.

They state in their README that the correct way to install gulp 4.0 is to run the command:

npm install gulp@next

syastrov
  • 656
  • 6
  • 6
  • 1
    In my case, I had to remove the old gulpjs/gulp.git#4.0 reference in package.json, and do a fresh npm install gulp --save-dev – Matt Beckman Jan 03 '19 at 21:13
  • Good thing NPM gives the great error of "Command failed: git checkout 4.0" Had to dig through the log to see what is actually causing this... – Alexander Jul 31 '19 at 17:17
  • npm ERR! code ETARGET npm ERR! notarget No matching version found for gulp@next. – therobyouknow Dec 06 '20 at 22:29
31
npm install gulpjs/gulp.git#4.0 --save-dev
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Andor Lundgren
  • 411
  • 3
  • 8
  • Is there a way to install this via devDependencies in a package.json file? I can't seem to resolve beta gulp 4 since it's pre-release. – Peder Rice Apr 19 '16 at 21:48
  • 5
    @PederRice ```"devDependencies": { "gulp": "github:gulpjs/gulp#4.0" }``` – atilkan May 15 '16 at 05:16
  • 5
    How do people know that from the beginning? I'm guessing you looked it up somehow and not guessed by trial-and-error. I've seen similar for other alpha stage packages and I can't see any systematics in there. Personally, I'd like something like *npm install packagename --latest* or something. How did you do it? – Konrad Viltersten Nov 16 '16 at 13:38
15

Run the following to check the version of gulp cli that is installed on your machine.

gulp -v

If you are not running version 4, do the following to install gulp globally on your machine.

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

Now install gulp 4 locally

npm uninstall gulp --save-dev
npm install "gulpjs/gulp#4.0" --save-dev
ciscoheat
  • 3,719
  • 1
  • 35
  • 52
T M
  • 516
  • 5
  • 18
  • 7
    There's no point installing gulp package globally. What you need globally is gulp-cli, which is already compatible with 4.0. So: `npm install -g gulp-cli` – metalim May 30 '17 at 18:01
11

November 2018 » npm audit says to run: npm install --save-dev gulp@4.0.0

August
  • 698
  • 4
  • 12
  • 21
3

to install gulp-4, CLI version has to be 1.2.2 which will support gulp 4.0

to install gulp-cli 1.2.2 run sudo npm install gulp-cli@1.2.2 -g

and to install gulp 4.0 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

similar issue on GitHub

Rajath M S
  • 1,092
  • 2
  • 18
  • 28
2

My installation was a bit different.

Running

npm install 'gulpjs/gulp.git#4.0' --save-dev

Or

npm install 'gulpjs/gulp#4.0' --save-dev

Gave me an error:

npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name "gulp#4.0": Tags may not have any characters that encodeURIComponent encodes.

NB I was only having problems installing my local gulp-4 so I took a look at my last package.json installation and saw this:

"gulp": "github:gulpjs/gulp#4.0",

So my move was to install local gulp with

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

and that worked, installing local gulp 4 successfully.

[15:45:55] CLI version 1.4.0
[15:45:55] Local version 4.0.0-alpha.2
ArchNoob
  • 3,946
  • 5
  • 32
  • 59
2

As of December 28th 2018, the following command should work perfectly fine in installing version 4 locally.

npm i -D gulp
klewis
  • 7,459
  • 15
  • 58
  • 102
1

I wrote a batch file that does the job based on what @demisx answered.

The problem I had was a missing npm config parameter 'prefix', so my global directory was the node binary directory. I am pretty sure this wasn't always the case, but I could (re-)set it running this script from the project root directory:

@ECHO OFF
echo configuring npm
set USERNAME=<enter username>
set USERPROFILE=C:\Users\%USERNAME%
set APPDATA=%USERPROFILE%\AppData\Roaming
call npm config set prefix %APPDATA%\npm

SET DIR_PROJECT="D:/stuff/plugins/wallpaper_engine/raintime-dev"

echo Uninstall previous Gulp installation and related packages, if any
call npm rm gulp -g
call npm rm gulp-cli -g

echo cd %DIR_PROJECT%
cd /D %DIR_PROJECT%

call npm rm gulp --save-dev
call npm rm gulp --save
call npm rm gulp --save-optional
call npm cache clean

echo Install the latest Gulp CLI tools globally
call npm install gulpjs/gulp-cli -g

echo Install Gulp 4 into your project from 4.0 GitHub branch as dev dependency
rem call npm install gulpjs/gulp#4.0 --save-dev
call npm install gulpjs/gulp --save-dev

echo Check the versions installed.

call gulp -v

pause

The script finally showed this:

[14:59:48] CLI version 2.0.1
[14:59:48] Local version 4.0.0

Hope it helps!

Manticore
  • 1,284
  • 16
  • 38
1

I solved the issue by running:

which gulp
rm -rf /usr/local/bin/gulp
npm i -g gulp
Jesus Sandrea
  • 335
  • 2
  • 4
  • 14
0

Windows still wouldn't upgrade. The below commands from another Linux post seemed to clear it out, and afterwards success.

Can't seem to upgrade gulp to 4.0 from 3.9

Uninstall previous Gulp installation and related packages, if any:

$ npm rm gulp -g
$ npm rm gulp-cli -g
$ cd [your-project-dir/]
$ npm rm gulp --save-dev
$ npm rm gulp --save
$ npm rm gulp --save-optional
craigcaulfield
  • 3,381
  • 10
  • 32
  • 40