Fixing the error “ReferenceError: primordials is not defined” in Gulp
Last modified: 18th October 2024
I have some legacy projects that use Gulp 3, which often bring up the error:
ReferenceError: primordials is not defined
After I’ve installed Node Modules, and when I try to run gulp.
To solve the “ReferenceError: primordials is not defined” error in Gulp v3 on Node.js 12, you can follow these steps:
Remove Dependencies:
Delete the node_modules
folder.
2. Create npm-shrinkwrap.json
Create a file named npm-shrinkwrap.json
in your project directory with content specifying version 4.2.2 of graceful-fs
.
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
Install Dependencies Again
Run npm install
to install the dependencies with the updated versions.
And voila! Your project should now run! This workaround is only if you want to avoid upgrading to Gulp v4 and need to get a Gulp v3 project up and running.
Don’t forget to add npm-shrinkwrap.json to gitignore!
Once you’ve run npm install again, your npm-shrinkwrap.json file will now be updated with the content it needs to get the project running. This will only work on your own machine, so it’s best to add npm-shrinkwrap.json to your gitignore, other team members will need to run their own npm-shrinkwrap.json file.