nodejs version management using wrong version when installing modules - node.js

I am using node version management from https://github.com/tj/n
$ node --version
v4.2.4
$ npm --version
1.3.1
I have removed my node_modules and tried to run $npm install but i get warning messages such as
npm WARN engine postcss#5.0.13: wanted: {"node":">=0.12"} (current: {"node":"v0.10.25","npm":"1.3.10"})
i have updated my packages.json to include:
"engineStrict" : true,
"engines": {
"node": "4.2.4"
},
any advice much appreciated
what am i missing

i needed to open a new terminal window for the settings to take effect.

please use nodejs v12.0
- download : https://nodejs.org/download/release/v0.12.0/node-v0.12.0.tar.gz (extract, make & make install)
After install nodejs v12.0, please retry it.

what tcss wanted node version ">=0.12", your node current version "0.10.25"
try to uninstall your old version, and reinstall node 4.2.4

Related

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in the package.json of a module in node_modules

This is a React web app. When I run
npm start
This error occurred
> dataflow#0.1.0 start
> react-scripts start
node:internal/modules/cjs/loader:488
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /Users/juliantc/Desktop/ai-studio/development/frontend/node_modules/postcss-safe-parser/node_modules/postcss/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:416:9)
at packageExportsResolve (node:internal/modules/esm/resolve:669:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/juliantc/Desktop/ai- studio/development/frontend/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v17.0.1
This error only occurs when I run this on this specific computer, which I do not have superuser access to. It works on other computers.
For reference, this is ./node_modules/postcss-safe-parser/node_modules/postcss/package.json
{
"name": "postcss",
"version": "8.2.6",
"description": "Tool for transforming styles with JS plugins",
"engines": {
"node": "^10 || ^12 || >=14"
},
"exports": {
".": {
"require": "./lib/postcss.js",
"import": "./lib/postcss.mjs",
"types": "./lib/postcss.d.ts"
},
"./": "./"
},
"main": "./lib/postcss.js",
"types": "./lib/postcss.d.ts",
"keywords": [
"css",
"postcss",
"rework",
"preprocessor",
"parser",
"source map",
"transform",
"manipulation",
"transpiler"
],
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
"author": "Andrey Sitnik <andrey#sitnik.ru>",
"license": "MIT",
"homepage": "https://postcss.org/",
"repository": "postcss/postcss",
"dependencies": {
"colorette": "^1.2.1",
"nanoid": "^3.1.20",
"source-map": "^0.6.1"
},
"browser": {
"./lib/terminal-highlight": false,
"colorette": false,
"fs": false
}
}
And this is what I get when I list the files in ./node_modules/postcss-safe-parser/node_modules/postcss/lib/
lgtd-lt-119-mbmt:frontend juliantc$ ls ./node_modules/postcss-safe-parser/node_modules/postcss/lib/
at-rule.d.ts css-syntax-error.d.ts input.d.ts map-generator.js postcss.d.ts processor.js rule.js tokenize.js
at-rule.js css-syntax-error.js input.js node.d.ts postcss.js result.d.ts stringifier.js warn-once.js
comment.d.ts declaration.d.ts lazy-result.d.ts node.js postcss.mjs result.js stringify.d.ts warning.d.ts
comment.js declaration.js lazy-result.js parse.d.ts previous-map.d.ts root.d.ts stringify.js warning.js
container.d.ts fromJSON.d.ts list.d.ts parse.js previous-map.js root.js symbols.js
container.js fromJSON.js list.js parser.js processor.d.ts rule.d.ts terminal-highlight.js
I am also stuck with the same problem because I installed the latest version of Node.js (v17.0.1).
Just go for node.js v14.18.1 and remove the latest version just use the stable version v14.18.1
nvm uninstall <version>
OR
nvm uninstall v17.0.1
then install the LTS one which is v14.18.1
nvm install --lts
This worked for me.
Remove node_modules folder and .lock file and re-install your packages (yarn or npm).
It worked for me with last 17.0.1 of nodejs, I can npm (or yarn) start my app again.
my working solution was with yarn:
removed /node_modules and yarn.lock file.
then reinstalled my deleted packages/file using yarn install .
it worked !!!
Roll back to Node 16.8.0 or (works for me) stable version 16.13.0:
Step 1: install n
npm install -g n
Step 2: install/set node latest stable version
sudo n stable
or set 16.8.0
sudo n 16.8.0
Note, if you can't or don't want to use sudo for n, you can set environment variables for the location, eg;
export N_PREFIX=$HOME/.n
export PATH=$N_PREFIX/bin:$PATH
FWIW, I bumped into this issue on macOS Monterey with Node 17.0.1 installed via Homebrew. Downgrading to Node 16.x worked for me.
Downgrade from Node 17.x (latest) to Node 16.x using Homebrew:
brew uninstall --ignore-dependencies node
brew install node#16
brew link node#16
removing and reinstalling lock and node modules didn't help but npm update worked for me
After removing node_modules & package-lock.json, I ran
npm audit fix --force
& updated react-scripts to the latest available version with
npm install react-scripts#latest
I also get the error when using Node.js v17.0.1 (Lates Features) - I am using macOS Catalina and homebrew.
So I want to switch Node.js v17.0.1 to Node.js (LTS) -> Node.js v16.3.1
I uninstall node using homebrew with the following command:
brew uninstall node
Then I download Node LTS from https://nodejs.org/en/ and install it.
That is work for me. Thanks :)
I had this issue with craco and postcss. What I did to solve is
npm i -D postcss#latest
export NODE_OPTIONS=--openssl-legacy-provider
npm install
You don't need to roll back to older node versions.
On node.js v18 I solved it by removing the node_modules folder and the package-lock.json file:
rm -rf node_modules package-lock.json
...then running:
npm i
npm audit fix
My next npm start worked just fine.
This problem can be occur when you are trying to work with an old react repository which is developed with a lower node.js version than v17.0.1 and you are currently using v17.0.1 or a higher node version.
Delete your node_modules folder, package-lock.json and yarn
file (if you have one).
Force clean the entire NPM cache by using following command. While executing this command, you might get a warning, just ignore it.
npm cache clean --force //WARN using --force Recommended protections disabled.
Re-Install all the dependencies.
npm install
I was receiving
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in ...node_modules\next\node_modules\postcss\package.json
I have resolved it on node version 17.4.0 after I upgraded react, and nextjs using:
npm install react#latest react-dom#latest
npm install next#12
(https://nextjs.org/docs/upgrading)
I just did:
npm update
npm start
worked for me.
I don't get why #AnmolNoor wants you to uninstall version 17.
The proper way:
Make sure you have nvm (https://github.com/nvm-sh/nvm). If you don't, I highly recommend installing it.
Check your node --version
If the version is 17, this might be the reason for the error (as it was in my case)
Run nvm install 14. After installing is complete, it should also switch your node version to 14.
Check the version node --version just in case. If you still see 17, run nvm use 14
Your node --version should now be 14.
Note: Every time you close the current terminal tab, your default node version will return back to 17 unless you change this.
Next time you have to switch node version to 14, you don't have to install it again, just run nvm use 14
Remove node_module & package-lock.json
then
npm install
( in install if you get error as to use --force and --legacy-peer-deps the command as
`npm install --legacy-peer-deps`
)
npm start
An update to the latest version of "react-scripts" have been worked for me! Previous "react-scripts" version was 4.0.3 and I've updated to 5.0.0. Node version is 17.0.1.
If you use yarn you can:
rm -rf node_modules yarn.lock
yarn add -D react-scripts#latest
yarn build
For npm:
rm -rf node_modules package-lock.json
npm install -D react-scripts#latest
npm install
npm run build
I faced similar issue and it was due to node version v17.1.0.
I have nvm with 3 different versions of node installed. Just switched to version v14.18.1 using nvm and the issue resolved.
Uninstalling the current Node.js and installing LTS solves the problem, but if you want to keep the currently installed version, you could use nvs add lts to install the latest Node.js LTS, and activate it using nvs use node/<lts version>/<platform>. The LTS version and Platform values will be provided in the first command output.
I had the same problem 5 minutes ago, which is strange because it was working, but anyway, in my case the problem was in version 3.0 of the package "resolve-url-loader", after upgrading to version 5.0, everything has been resolved.
npm i resolve-url-loader#^5.0.0 --save-dev
If you have this package and node 17+, try to update it to the latest version, outdated versions cause problems like this.
If you hit an error in your application with Node.js 17, it’s likely
that your application or a module you’re using is attempting to use an
algorithm or key size which is no longer allowed by default with
OpenSSL 3.0. A command-line option, , has been added to revert to the
legacy provider as a temporary workaround for these tightened
restrictions.ERR_OSSL_EVP_UNSUPPORTED--openssl-legacy-provider
For details about all the features in OpenSSL 3.0 please see the
OpenSSL 3.0 release blog.
Contributed in https://github.com/nodejs/node/pull/38512,
https://github.com/nodejs/node/pull/40478
https://nodejs.org/en/blog/release/v17.0.0/#openssl-3-0
For me, I updated the Node version to the v16.17.1 and removed and reinstall packege.json, now it is fixed

The engine "node" is incompatible with this module. Expected version "7.5.0". Got "15.13.0"

one of my friends sent me a project using react and node and i tried to run it with yarn. Each time i run this command i got this error : The engine "node" is incompatible with this module. Expected version "7.5.0". Got "15.13.0". I just want to know how update the react version of a project
Have a good day
You can change your package.json
"engines": { "node": ">=7.5.0"},
This will make the projects run with node 7.5.0 or newer versions. Also using nvm
nvm install version_you_want
nvm use version_you_want
Check node and npm versions
node -v
npm -v
Other option is to use
yarn install --ignore-engines
See this post: How to fix engine "node" version?
In my case I was gettin the same error because I didn't set the .env file
You could use this npm package, but be aware of breaking changes especially as it seems to be a very old version.
A better approach may be to use nvm - node version manager (or nvm-windows if that is your operating system) to install and use an older - compatible version of node, e.g. v7.5.0.

How to fix "ReferenceError: primordials is not defined" in Node.js

I have installed Node.js modules by 'npm install', and then I tried to do gulp sass-watch in a 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
I have tried this before gulp sass-watch:
npm -g install gulp-cli
I hit the same error. I suspect you're using Node.js 12 and Gulp.js 3. That combination does not work: Gulp.js 3 is broken on Node.js 12 #2324
A previous workaround from Jan. does not work either: After update to Node.js 11.0.0 running Gulp.js exits with 'ReferenceError: internalBinding is not defined' #2246
Solution: Either upgrade to Gulp.js 4 or downgrade to an earlier version of Node.js.
We encountered the same issue when updating a legacy project depending on gulp#3.9.1 to Node.js 12+.
These fixes enable you to use Node.js 12+ with gulp#3.9.1 by overriding graceful-fs to version ^4.2.10.
If you are using pnpm
pnpm supports overriding some dependencies versions. To do it, you should add a pnpm section in your package.json file:
{
"pnpm": {
"overrides": {
"graceful-fs": "^4.2.10"
}
}
}
If you are using yarn v1
Yarn v1 supports resolving a package to a defined version.
You need to add a resolutions section to your package.json:
{
"resolutions": {
"graceful-fs": "^4.2.10"
}
}
Thanks #jazd for this way to solve the issue.
If you are using npm
Run this command to know which version of Node.js you are using:
node -v
It will return a version number <major>.<minor>.<patch> such as 18.11.0.
If your version is v16.14.0 or above, then you can override the version of graceful-fs by adding an overrides section in your package.json file:
{
"overrides": {
"graceful-fs": "^4.2.10"
}
}
Otherwise, you need to use npm-force-resolutions as a preinstall script to be able to override the version of graceful-fs by changing your package.json file like this:
{
"scripts": {
"preinstall": "npx npm-force-resolutions"
},
"resolutions": {
"graceful-fs": "^4.2.10"
}
}
npm-force-resolutions will alter the package-lock.json file to set graceful-fsto 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 some versions of npx don't use the current folder .npmrc file by default.
Origin of the problem
This issue stems from the fact that gulp#3.9.1 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, 14 and 16).
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.
Fix it in one minute:
Just follow these steps. I'm on Windows 10 and it worked perfectly for me!
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 will update npm-shrinkwrap.json with a bunch of content.
Run gulp to start the project.
Use the following commands and install Node.js 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.
Use the following commands to install Node.js v11.15.0 and Gulp.js v3.9.1:
npm install -g n
sudo n 11.15.0
npm install gulp#^3.9.1
npm install
npm rebuild node-sass
It will solve this issue:
ReferenceError: primordials is not defined in node
For me, Diego Fortes' answer works with one small change.
Here is my workflow if this error appears:
npm install
npm install gulp
create file npm-shrinkwrap.json with
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
npm install (again) (Not npm install gulp again! Very important - otherwise the error will be come back)
gulp (now working)
Using NVM to manage what Node.js 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.
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.js v 11.x.x (the 11.15.0 version worked fine for me) by simply using the following code in a 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
TL:DR
Gulp 3.* doesn't work on Node.js 12.* or above. You have to downgrade Node.js, or upgrade Gulp.
If you are short on time, downgrade Node.js 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.js 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 rewriting your gulpfile to a new syntax, and might (read: probably will - see end of this comment) cause conflicts with some dependencies.
Downgrading Node.js
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.js versions.
Installing Node.js version on N
n 10.16.0
Installing a Node.js version on NVM
nvm install 10.16.0
Once 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 reinstalling your dependencies. Though if you are merely reverting to a preexisting Node.js version, you should probably be fine.
Upgrading Gulp
As mentioned above, this is a more time-intensive task, but it might bring benefits in the long run. For example, Node.js 12 has now introduced native support for ES Modules (behind an experimental flag) and full support in Node.js 13.
You may need to upgrade Node.js 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 rewriting required, and you may have dependencies that break. If you are in short supply of time, you should opt for simply downgrading Node.js, at least temporarily.
But I already have Gulp 4, and it still doesn't work!
If, like me, you are already using Gulp 4+ (I was using Gulp 4.0.2, originally on Node.js 10) and have recently upgraded (I upgraded to Node.js 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 an 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.js, at least until patches can be issued.
I had the same error. I finally fixed that when I updated all packages and then mentioned the same Node.js 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, check out Heroku support.
Check Node.js version:
node --version
Check gulp version:
gulp -v
If Node.js >=12 and gulp <= 3, do one of the following:
Upgrade gulp
sudo npm install -g gulp
Downgrade node
sudo npm install -g n
sudo n 11.15.0
How to Upgrade (or Downgrade) Node.js Using npm
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.js > v11.
Try this:
npm install -g n
sudo n 11.15.0
The problem occurred for me in Visual Studio's Task Runner Explorer only and not when running from the command line or PowerShell.
I realised that VS was ignoring the Node version I had set with NVM.
This post gave the answer: Configure which NPM is used by Visual Studio's Task Runner Explorer? by setting the PATH variable as a higher priority than external tools in VS, it used the Node version set by NVM and not the version installed with VS.
This error is because of the new version of Node.js (12) and an old version of Gulp (less than 4).
Downgrading Node.js and other dependencies isn't recommended. I solved this by updating package.json file, fetching the 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: Gulp 4: The new task execution system - gulp.parallel and gulp.series, Migration
Before:
gulp.task(
'sass', function () {
return gulp.src([sourcePath + '/sass/**/*.scss', "!" + sourcePath + "/sass/**/_*.scss"])
....
}
);
Other configuration...
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.js stable fixed this issue for me, as it occurred after I upgraded to Node.js 12:
sudo n 10.16.0
I faced the same issue. What I tried and what worked for me:
Check the version of Node.js and Gulp.js (a combination of Node.js v12 and Gulp.js less than v4 doesn't work)
I downgraded the NPM version by:
sudo NPM install -g n
sudo n 10.16.0
It worked fine. Then just follow the instructions of your console.
Upgrade to 4.0.1 and make sure to migrate https://fettblog.eu/gulp-4-parallel-and-series/#migration
I was getting this error on Windows 10. It 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.
If keeping Node.js 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 file
"dependencies": {
"gulp": "^4.0.0"
}
Delete your package-lock.json file.
Delete your node_modules folder.
Finally, run npm i to upgrade and recreate a 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: How to Migrate to Gulp.js 4.0
I fixed this issue on Windows 10 by uninstalling Node.js 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 you're running Windows 64-bit.
If you're trying to install semantic-ui and the following error occurs then try downloading the latest version of Node.js js(13.5.0) with the latest features, from Node.js.org.
Moreover, rather than trying the NPM install semantic, you should just add the link (which you can find from the cdnjs link) to the header of your index.html file.
Gulp is making issue with Node.js version 11 and above. Uninstall your current Node.js version and reinstall the v10.15.1 version. Here is the link for that version. This helps me and it will solve your problem too.
https://nodejs.org/download/release/v10.15.1/
Install gulp and add your Node.js version to the package.json file like so:
{
"dependencies": {
"node": "^10.16.3"
}
}
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;
Uninstall Node.js from "Add or remove programs". Fire up a new Command prompt and type gulp -v and then node -v to check that it has been uninstalled completely.
Download and install Node.js v10.16.0 - not the latest as latest node & gulp combination is causing the problem as far as I see. During installation I didn't change the installation path which I normally do(C:\Program Files\nodejs).
Open up a new Command prompt, go to your project's directory where you have got your gulpfile.js and start gulp as shown in the image.
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.
Update: Today I had the same problem while setting up one of my existing projects on my new PC and I did the same steps + went to the directory where I have the gulpfile and then run npm install.
It seems you've upgraded your nodejs's version to be +12 and still using gulp 3.9.1
You can use one of the below solutions
Upgrade you glup version to be +4
Or simply you use NVM Node version Manager
To run multiple nodejs versions on the same machine.
I had this very same error, but it was caused by a different issue.
OS: windows 10
nodejs version: 15.12.0
npm version: 7.6.3
The cause of the problem was graceful-fs package.
Whenever I tried to run npm, even running npm-v was firing "ReferenceError: primordials is not defined".
I tried running npm install graceful-fs#latest, but it still didn't work, even though the package was latest version.
So what helped me?
run npm ls graceful-fs
This way you'll find all packages on which graceful-fs is dependency and which version it has. In my case it was mostly version 3.0, even though I've installed version 4.2.6
So how to fix it?
Open npm-shrinkwrap.json (not sure about packages-lock.json) and change search for graceful-fs - you'll see that it has older versions on a few places. Replace it with ^4.2.6 (or newer).
Then npm audit fix --force which will forcefully install the newer version everywhere.
Hope this works for you, it took me a few hours to find out how to fix it.
Since my project was using gulp version 4, I had to do the following to solve this
Delete folder node_modules
open package.json and update version
Here is the detail of version I am using
Now run npm install and then run gulp default. The error should be gone and you may see:
Task never defined: default only.
Remove package-lock.json or yarn.lock file.
Then remove node_modules.
After that modify the package.json file-
"dependencies": {
"gulp": "^4.0.0"
}
Then run- npm install
It will be enough to solve this problem.
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.

error eslint#5.6.0: The engine "node" is incompatible with this module. when trying to create-react-app

I am trying to create a React App and I am getting the following error in my console.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
yarn add v1.10.1
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning react-scripts > eslint > file-entry-cache > flat-cache > circular- json#0.3.3: CircularJSON is in maintenance only, flatted is its successor.
[2/4] 🚚 Fetching packages...
error eslint#5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "9.5.0"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact react react-dom react-scripts --cwd /Volumes/server2/Desktop/JavaScript/birdcage has failed.
Deleting generated file... package.json
Deleting birdcage / from /Volumes/server2/Desktop/JavaScript
Done.
I have tried brew upgrade node but that didn't seem to work. Any ideas on how this can be fixed would be greatly appreciated.
One of the temporally fix is to run yarn install --ignore-engines
I was facing the same issue, try to add "--use-npm" at the end of create react app commend.
create-react-app appname --use-npm
I had the same problem, simply doing this solved the problem:
npm install node#latest
Try to uninstall yarn and install it via npm.
npm i create-react-app -g
create-react-app yourappname
Make sure that node is installed!
I had the same problem, try it:
yarn config set ignore-engines true
I re-installed node and updated xcode developer tools. Also, re-installed React on that computer which is running Mojave.
Assuming nvm is installed, use it to see which version of node you're using, then use it to change to a later version.
you can change the version with nvm use <version> and then try again
In my Ubuntu 18.04 had a native version from the OS installed that not listed by NVM.
I removed it and then I ran:
Firstly run, nvm install 14.5.0
then run, nvm use 14.5.0
And the installation completed properly.
i had same issue when i was adding router plugin to vue-cli with npx and yarn as well..
In pyhton virtual environment i have updated node version from 8.x.x to 16.x.x and used command nvm use 16.x.x but still problem persists .. i was actually executing command as root .. so nvm is using node version as 8.x.x only ..
after long time i realised executing command with sudo was the issue and then executed as a normal user...
this solution worked for me !!!
As the warning said, I updated node via nvm to the version required. For me having the latest node lts version was enough.
nvm install "lts/*" --reinstall-packages-from="$(nvm current)"
But even after upgrading node, yarn still gave the error.
The problem was npm was still executed from the old .bin path of previous node version. nvm also installs latest version of npm in respective local .bin folder for the node version installed.
I used the following commands then,
nvm install-latest-npm: Attempt to upgrade to the latest working npm on the current node version
nvm install --latest-npm: After installing, attempt to upgrade to the latest working npm on the given node version
After this, it worked properly.
Reference:
How can I change the version of npm using nvm?

Install Apache Cordova on Archlinux

I installed it with
yaourt nodejs-cordova
I have the following settings:
node -v
v5.0.0
npm -v
3.3.10
which node
/usr/bin/node
which npm
/usr/bin/npm
Now I tried this:
sudo npm install -g cordova
But as result I get this:
npm WARN engine xmlbuilder#2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"5.0.0","npm":"3.3.10"})
/usr/bin/cordova -> /usr/lib/node_modules/cordova/bin/cordova
/usr/lib
└── cordova#5.3.3
Is it a version problem?
Can anyone help me?
Because now, when trying to create a new project I get this:
Creating a new cordova project.
Could not find directory: /usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-app-hello-world
It's hard to say with the output you've shown, but there is some dependency of cordova that is depending on an outdated version of xmlbuilder.
Newer versions of xmlbuilder use a different node version compatibility specifier:
"engines": {
"node": ">=0.8.0"
},
This makes it compatible with newer versions of node.js (including v5.0.0).
EDIT:
Here is the dependency tree for cordova. In there we see that the problematic dependency link goes like cordova#5.3.3 -> cordova-lib#5.3.3 -> plist#1.1.0 -> xmlbuilder#2.2.1. So then looking at each project in the chain, it's evident that several things need to happen:
An issue needs to be created at the plist issue tracker telling them to publish a new version because they already have their package.json pointing to the newer xmlbuilder with the fixed engines list.
After that is done, an issue needs to be created on the cordova issue tracker (requires a JIRA account there) telling them to update their dependency to use the newly published plist.
I found the solution on this site: https://ervinloh.wordpress.com/2015/06/07/solving-npm-warn-engine-cordova-js3-8-0-wanted-warning/
It is possible to force npm to install the newest Cordova version with:
npm install -g cordova#4
Doing this, everything works fine.

Resources