Gulp 3.*
doesn't work on Node 12.*
or above. You have to downgrade Node, or upgrade Gulp.
If you are short on time, downgrade Node to
v11.*
or below; if you need newer features, and have time to possibly fix a load of broken dependencies, upgrade Gulp to4.*
or above!
As others have already mentioned, Gulp 3.*
is not supported on Node 12
or above, so you will have to downgrade your Node version to 11.*
or below, OR upgrade your Gulp to 4.0
.
The best option depends ultimately on how much time you have, as upgrading Gulp brings benefits of cleaner gulpfiles and in-built control over having tasks run in series or parallel, but also relies on you re-writing your gulpfile to a new syntax, and might (read: probably will - see end of this comment) cause conflicts with some dependencies.
This is the easiest and quickest option. Especially if you use n or nvm, as these allow you to very quick install and switch between Node versions.
n 10.16.0
nvm install 10.16.0
One you have done this, you may need to rebuild your npm dependencies or alternatively remove both your node_modules folder AND your package-lock.json file and re-installing your dependencies. Though if you are merely reverting to a pre-existing Node version, you should probably be fine.
As mentioned above, this is a more time-intensive task, but might bring benefits in the long-run. For example, Node 12 has now introduced native support for ES Modules (behind an experimental flag) and full support in Node 13.
You may need to upgrade Node to use that, forcing you to upgrade Gulp. Or you may simply want the benefits of using Gulp 4, as it offers better and more efficient control over writing tasks.
There are a number of articles on this already, so I won't elaborate any further on the specifics, but to reiterate - this is not a quick job. Depending on the size of your project, there may be some notable re-writing required, and you may have dependencies that break. If you are in short supply of time, you should opt for simply downgrading Node, at least temporarily.
If, like me, you are already using Gulp 4+ (I was using Gulp 4.0.2
, originally on Node 10) and have recently upgraded (I upgraded to Node 13.8.0
) are you are still getting the issue, it may be because a dependency is relying on an older version of Gulp, and that is getting caught in the pipeline.
In my case, gulp-combine-mq
was a dependency using Gulp 3.9.*
. Disabling this task in my gulpfile allowed Gulp to run again.
If this happens, you have a few options: you can,
- Go without the plugin if it's not absolutely necessary
- Find an alternative,
- Fix the plugin
Needless to say, if you have several plugins that rely on older version of Gulp - especially if these plugins are vital for your application - this is where there can be a huge additional chunk of time spent in upgrading Gulp (hence the warnings above).
If this happens, it is best to just downgrade Node, at least until patches can be issued.