I have installed node modules by npm install, then I tried to do gulp sass-watch in command prompt. After that I got the below response.
[18:18:32] Requiring external module babel-register
fs.js:27
const { Math, Object, Reflect } = primordials;
^
ReferenceError: primordials is not defined
Have tried this before gulp sass-watch
npm -g install gulp-cli
This might have come in late but for anyone still interested in keeping their Node v12 while using the latest gulp ^4.0, follow these steps:
Update the command-line interface (just for precaution) using:
npm i gulp-cli -g
Add/Update the gulp
under dependencies section of your package.json
"dependencies": {
"gulp": "^4.0.0"
}
Delete your package-lock.json
file
Delete your node_modules
folder
Finally, Run npm i
to upgrade and recreate brand new node_modules folder and package-lock.json file with correct parameters for Gulp ^4.0
npm i
Note Gulp.js 4.0 introduces the series()
and parallel()
methods to combine tasks instead of the array methods used in Gulp 3, and so you may or may not encounter an error in your old gulpfile.js
script.
To learn more about applying these new features, this site have really done justice to it: https://www.sitepoint.com/how-to-migrate-to-gulp-4/
(If it helps, please leave a thumps up)
What worked for me was to use python2 during npm installation.
> npm install --python=~/venv/bin/python
I have tried a lot of suggestions to fix this problem for an existing project on my Windows 10 machine and ended up following these steps to fix it;
gulp -v
and then node -v
to check that it has been uninstalled completely.Please note sometimes when I switch between git branches I might need to close my Visual Studio and run it as Admin again in order to see this solution working again.
As far as I see this problem started to happen after I installed the latest recommended version(12.18.4) of Node.js for a new project and I only realised this when some FE changes weren't reflected on the existing web project.
Upgrade to 4.0.1 and make sure to migrate https://fettblog.eu/gulp-4-parallel-and-series/#migration
Using NVM to manage what node version you're using, running the following commands worked for me:
$ cd /to/your/project/
$ nvm install lts/dubnium
$ nvm use lts/dubnium
$ yarn upgrade # or `npm install`
Simple and elegant solution
Just follow these steps. It worked perfectly with npm install running multiple times or installing any other modules or even publishing project to artifactory.
In the same directory where you have package.json create a npm-shrinkwrap.json file with the following contents:
{
"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. Let's get rid of this updates by updating package.json scripts options.
"scripts": {
"preshrinkwrap": "git checkout -- npm-shrinkwrap.json",
"postshrinkwrap": "git checkout -- npm-shrinkwrap.json"
}
Now you can run npm install and your npm-shrinkwrap.json will be intact and will work forever.
I got the same issue installing the npm package https://www.npmjs.com/package/webshot
NOTE: it was a known issue for that package as it depends on graceful-fs behind the scenes.
FIX:1. upgrade graceful-fs to 4.x or higher
fix:2. use webshot-node instead https://www.npmjs.com/package/webshot-node
If you're trying to install semantic-ui
and the following error occurs then try downloading the latest version of node js(13.5.0)
with the latest features, from Node.js.org, Moreover rather than trying NPM install semantic you should just add the link (which you can find from cdnjs link to the header of your index.html
file.
Best of luck!
Solved by downgrading Node.js version from 12.14.0
to 10.18.0
and reinstalling node_modules
.
Check node version:
node --version
Check gulp version:
gulp -v
If node >=12 and gulp <= 3, do one of the following:
sudo npm install -g gulp
sudo npm install -g n
sudo n 11.15.0
https://www.surrealcms.com/blog/how-to-upgrade-or-downgrade-nodejs-using-npm.html
Gulp is making issue with Nodejs version 11 and above. Uninstall your current node version and reinstall the v10.15.1
here is link for that version. This helps me and it will solve your problem too.
This is because the compatibility issue between node
and gulp
in your system. Downgrading the node
or upgrading the gulp
will fix this issue.
sudo npm i -g n
sudo n 11.15.0
Try removing the node_modules
folder and package-lock.json
file and installing again using npm i
command if still not working.
I was also getting error on Node 12/13 with Gulp 3, moving to Node 11 worked.
I faced the same issue. What I tried and worked for me:
Check the version of NODE and GULP (combination of node v12 and gulp less than v4 doesn't work)
I downgrade NPM version by:
It worked fine, then just follow instruction of your console.
I was using node v12.13.1, so I've downgraded to v10.19.0 and works fine after that.
We encountered the same issue when updating a legacy project depending on [email protected]
to Node.js 12+.
These fixes enable you to use Node.js 12+ with [email protected]
by overriding graceful-fs
to version ^4.2.4
.
Yarn v1 supports resolving a package to a defined version.
You need to add a resolutions
section to your package.json
:
{
// Your current package.json contents
"resolutions": {
"graceful-fs": "^4.2.4"
}
}
Thanks @jazd for this way to solve the issue.
Using npm-force-resolutions
as a preinstall script, you can obtain a similar result as with yarn v1. You need to modify your package.json this way:
{
// Your current package.json
"scripts": {
// Your current package.json scripts
"preinstall": "npx npm-force-resolutions"
},
"resolutions": {
"graceful-fs": "^4.2.4"
}
}
npm-force-resolutions
will alter the package-lock.json
file to set graceful-fs
to the wanted version before the install
is done.
If you are using a custom .npmrc
file in your project and it contains either a proxy or custom registry, you might need to change npx npm-force-resolutions
to npx --userconfig .npmrc npm-force-resolutions
because as of now, npx
doesn't use the current folder .npmrc
file by default.
This issue stems from the fact that [email protected]
depends on graceful-fs@^3.0.0
which monkeypatches Node.js fs
module.
This used to work with Node.js until version 11.15 (which is a version from a development branch and shouldn't be used in production).
graceful-fs@^4.0.0
does not monkeypatch Node.js fs
module anymore, which makes it compatible with Node.js > 11.15 (tested and working with versions 12 and 14).
Note that this is not a perennial solution but it helps when you don't have the time to update to gulp@^4.0.0
.
For those who are using yarn
.
yarn global add n
n 11.15.0
yarn install # have to install again
I suggest you first make sure NPM install is not your problem. Then you downgrade node and gulp versions. I used node 10.16.1 and gulp 3.9.1.
To downgrade your gulp you can try
npm install gulp@^3.9.1
Just follow these steps. I'm on windows 10 and it worked perfectly for me!
package.json
create a npm-shrinkwrap.json
file with the following contents: {
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
Run npm install
, and don't worry, it will update npm-shrinkwrap.json
with a bunch of content.
Run gulp
to start the project.
This error is because of the new version of Node (12) and an old version of gulp (less than 4).
Downgrading Node and other dependencies isn't recommended. I solved this by updating package.json
file fetching latest version of all dependencies. For this, I use npm-check-updates
. It is a module that updates the package.json
with the latest version of all dependencies.
Reference: https://www.npmjs.com/package/npm-check-updates
npm i -g npm-check-updates
ncu -u
npm install
In most cases, we will have to update the gulpfile.js
as well like the following:
Reference: https://fettblog.eu/gulp-4-parallel-and-series/#migration
Before:
gulp.task(
'sass', function () {
return gulp.src([sourcePath + '/sass/**/*.scss', "!" + sourcePath + "/sass/**/_*.scss"])
....
}
);
Other config...
gulp.task(
'watch', function () {
gulp.watch(sourcePath + '/sass/**/*.scss', ['sass']);
}
);
After:
gulp.task('sass', gulp.series(function(done) {
return gulp.src([sourcePath + '/sass/**/*.scss', "!" + sourcePath + "/sass/**/_*.scss"])
...
done();
}));
Other config...
gulp.task(
'watch', function () {
gulp.watch(sourcePath + '/sass/**/*.scss', gulp.series('sass'));
}
);
Downgrading to node stable fixed this issue for me, as it occurred after I upgraded to node 12
sudo n 10.16.0
As we also get this error when we use s3 NPM package. So the problem is with graceful-fs package we need to take it updated. It is working fine on 4.2.3.
So just look in what NPM package it is showing in logs trace and update the graceful-fs accordingly to 4.2.3.
had same error and finally fix that when updated all packages and then mentioned the same node engine version and npm version in package.json
as it is in my local working system.
"engines": {
"node": "10.15.3",
"npm": "6.9.0"
}
i was getting this error when deploying on heroku.
for more checkout heroku support
Gulp 3.9.1 doesn't work with Node v12.x.x, and if you upgrade to Gulp 4.0.2, you have to completely change gulpfile.js with the new Syntax (Series & Parallels). So your best bet is to downgrade to Node V 11.x.x, the 11.15.0 worked fine for me. By simply using the following code in terminal:
nvm install 11.15.0
nvm use 11.15.0 #just in case it didn't automatically select the 11.15.0 as the main node.
nvm uninstall 13.1.0
npm rebuild node-sass
Use following commands to install node v11.15.0
and gulp v3.9.1
:
npm install -g n
sudo n 11.15.0
npm install gulp@^3.9.1
npm install
npm rebuild node-sass
Will solve this issue:
ReferenceError: primordials is not defined in node
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 to 4.* 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,
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.
For anyone having same error for the same reason in ADOS CI Build:
This question was the first I found when looking for help. I have an ADOS CI build pipeline where first Node.js tool installer task is used to install Node. Then npm task is used to install gulp (npm install -g gulp). Then the following Gulp task runs default-task from gulpfile.js. There's some gulp-sass stuff in it.
When I changed the Node.js tool to install 12.x latest node instead of an older one and the latest gulp version was 4.0.2. The result was the same error as described in the question.
What worked for me in this case was to downgrade node.js to latest 11.x version as was already suggested by Alphonse R. Dsouza and Aymen Yaseen. In this case though there's no need to use any commands they suggested, but rather just set the Node.js tool installer version spec to latest Node version from 11.x.
The exact version of Node.js that got installed and is working was 11.15.0. I didn't have to downgrade the Gulp.
I was getting this error on Windows 10. Turned out to be a corrupted roaming profile.
npm ERR! node v12.4.0
npm ERR! npm v3.3.12
npm ERR! primordials is not defined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
Deleting the C:\Users\{user}\AppData\Roaming\npm
folder fixed my issue.
Since my project was using gulp version 4 , I had to do the following to solve this
Here is the detail of version I am using
Now run npm install then run gulp default , the error should gone and you may see Task never defined: default only.
Have a good day.
Use following commands and install node v11.15.0:
npm install -g n
sudo n 11.15.0
will solve
ReferenceError: primordials is not defined in node
Referred from @Terje Norderhaug @Tom Corelis answers.
In case the problem is not from gulp
then check the unzip npm module. it's been around six years since the last time it was updated. it doesn't work with Node > v11.
Try this:
npm install -g n
sudo n 11.15.0
Steps To fix the Problem:-
I have fixed the problem with following steps:-
nvm install lts/dubnium
nvm install lts/dubnium
Now you can you gulp deploy
You Have Two Option Here
I fixed this issue on Windows 10 by uninstalling node from Add or remove programs -> Node.js
Then I installed version 11.15.0 from https://nodejs.org/download/release/v11.15.0/
Choose node-v11.15.0-x64.msi if your running windows 64bit.
Source: Stackoverflow.com