JavaScript
Dec 27, 2019 · Updated: Jan 04, 2021 · by Tim Kamanin
Are you getting a ReferenceError: primordials is not defined
error message when trying to run gulp? Chances are you're on gulp v3
and node v12
, and that's the source of the issue.
The thing is, gulp v3
doesn't work (as of now) under node v12
, because it depends on graceful-fs@^3.0.0
which patches Node's fs
module and that patch worked before node v12
just fine.
a) To upgrade gulp
to v4 - to me, that's not an option, and I don't want to re-write and re-config my frontend toolchain for Xth time.
b) To downgrade Node
to v11 - is also not an option to me, I don't want to jump through nvm
hoops or even think about juggling node environments
c) To pin graceful-fs
to version 4.2.2
that's known to work under Node v12
- that's the option I've chosen, let me tell how to use it.
To pin graceful-fs
to version 4.2.2
, we need to use an npm-shrinkwrap.json
file, which lets you lock down the versions of installed packages and their descendant packages. Anything specified in this file can't be overridden by package.json
content, which gives us what we need: pinning graceful-fs
at 4.2.2
despite whatever gulp 3
requires in package.json
.
In the same directory where you have package.json
create an npm-shrinkwrap.json
file with the following contents:
json
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
Run npm install
, and don't worry, it'll update npm-shrinkwrap.json
with a bunch of content.
Now, fire your gulp
command and enjoy, it should be working just fine!
P.S. Let's connect! Follow me on twitter @timonweb, so we could be in touch. I regularly share tips and interesting dev links there. See you.
Hey, if you've found this useful, please share the post to help other folks find it: