The engine "node" is incompatible with this module. Expected version "12.x". Got "14.8.0" - node.js

I try to do a yarn add, but I have this error:
The engine "node" is incompatible with this module. Expected version "12.x". Got "14.8.0"

Run these commands:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Then in your project directory run:
rm -r ./node_modules
rm ./yarn.lock
After this, yarn install | add | upgrade should work as expected.
P.S. If you are using the npm package manager, instead of rm ./yarn.lock run rm ./package-lock.json.

One time fix for the "the engine node is incompatible with this module" problem.
$ yarn install --ignore-engines

I can suggest 2 solutions :
1/ It works but it's probably not the best way
You just have to update your packages.json.
currently :
"engines": {
"node": "12.x"
}
updated :
"engines": {
"node": "14.8.0"
}
2/ I think it's a cleaner way
You can use nvm use x to use the Node version.
exemple : nvm use 14 to use node version 14

I had the same problem when I try to make a new app with react. When I do npx create-react-app my-app,
I get this error:
babel-jest#27.4.5: the engine "node" is incompatible with this module. expected version "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0". got "14.8.0"
I solved this problem with this which I found this on other stockoverflow answer.
I can't install react using npx create-react-app?
npm install -g create-react-app
This may help you.

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

npx create-react-app -> The engine "node" is incompatible with this module. Expected version ">= 10.x". Got "8.16.0" - Arch Linux

I know this has been here many times, but it just doesn't work. I use Arch Linux. Everytime I try to run
npx create-react-app my-app
or
npm create-react-app my-app
I get
error #pmmmwh/react-refresh-webpack-plugin#0.4.3: The engine "node" is incompatible with
this module. Expected version ">= 10.x". Got "8.16.0"
error Found incompatible module.
When I type node -v I get 14.16.1 and npm -v -> 7.10.0
Looks like the node version doesn't appear update to 14.x version. Maybe?
I have tried updating sudo npm install -g npm and sudo n stable.
When I try sudo npm install npm#latest -g I get a lot of Missing write access to /usr/local/lib/node_modules/.............
The fix was that I had installed node via pacman and via Snap Store (I didn't know about it) and I saw in WebStorm that there is some node v 8.16.0 installed. So i uninstalled the snap version and it's working. Looks like create-react-app was using the snap version

npm ERR! cb.apply is not a function

I am getting this error
npm ERR! cb.apply is not a function
in Linux while doing npm install although my npm version is 6.9.0. My node version is v12.18.3. How to resolve this issue?
Would be helpful if you shared if it's Windows or Linux, but the error seems to occur on Windows. Possible solution:
1. Go to C:\Users(your username)\AppData\Roaming
2. Delete the npm folder (possibly back it up) and if there is one npm cache folder.
3. Run `npm cache clear --force` (--force is now required to clean cache)
After that, npm install should work fine.
Mac/Macbook users
Since this question is fairly active and a top google result for this issue (I know the OP is using Linux), here is how to fix it on a Mac.
On a Mac you do not have the AppData\Roaming folder, so simply run npm root -g and then navigate to the hidden directory and delete the node_modules there. If using nvm you'll need to rerun nvm use x.x.x (where x.x.x is your version).
Solution for Windows:
In my case I didn't want to delete all the npm directory inside C:/users/me/AppData/Roaming/ because I had many global modules that already existed and installed.
What worked was inspired by #user14360499's answer:
go inside C:\Users\me\AppData\Roaming\npm\node_modules
delete the npm dir
npm install my project, and keep working as usually
Solution for ubuntu 18.04:
sudo apt-get remove nodejs
sudo apt-get remove npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/bin/npm
sudo apt-get install nodejs
sudo apt-get install npm
Then try node and npm version:
node -v
npm -v
If it says there is no such node/npm after you already install, then:
sudo ln -s /usr/bin/node /usr/local/bin/node
sudo ln -s /usr/bin/npm /usr/local/bin/npm
Try this if the command works:
npm -v
node -v
In case when you want to update npm/node stable version:
sudo npm install n -g
sudo n stable
I had the same issue with Nodist. After changing my Node version, my npm version was actually incompatible with it. So if you're using Nodist, make sure to run nodist npm {scope} match after switching Node versions, where scope is either global, local or env.
For me, on Centos 7, it was about removing graceful-ts used locally by npx. First, I've had to open log file which was mentioned in the error message:
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-04-04T07_45_27_182Z-debug.log
In that log file there was this path:
verbose stack at /usr/local/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
So I removed whole graceful-fs directory and ran npx again. Everything worked.
rm -fR /usr/local/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs
Had the same error (macOS Big Sur) when i tried to use npx.
How i fixed it (using nvm)
when i run:
nvm ls
nvm ls output
Fix:
nvm alias default node
nvm install 'lts/*'
nvm install output
Ciao, this problem could be connected to graceful-fs package. You could try to reinstall it:
npm install graceful-fs --save-dev
In my case it was indeed the graceful-fs package. Running
npm i -g --force graceful-fs
fixed the issue. I also ran nodist npm {scope} match before but I'm unsure if it was neccessary.
Solution for Ubuntu 18.04=>
Visit 'usr/lib/node_modules'.
Delete 'n', 'npm','npm-clean','npm-install-peers'. That means delete all the node & npm related folders.
Install the npm again.
I have tried a lot of solutions from different posts and google pages and nothing worked for me.
I ended up cleaning all traces of node, nodejs, and npm. May need some manual force remove after the purge call. And then installed using nvm.
https://linuxize.com/post/how-to-install-node-js-on-ubuntu-20-04/#installing-nodejs-and-npm-using-nvm
And it resolved the issue for me. It got the nodejs v 15.4.0 and the compatible version of npm 7.0.15 ( before using apt-get it was installing npm 6.9.0)
On macOS BigSur, I had this problem when executing:
npx install-peerdeps --dev eslint-config-airbnb
To fix, I ran
brew update
after which I was prompted to run
brew upgrade
Running the two commands fixed the issue.
I had this problem while trying to run npx.
I found that nvm had been removed from the PATH.
I added it back to my .zshrc file and it worked.
In my case (Mac) it was because I had npx installed alongside n (alternative to nvm).
$ which npx
/usr/local/bin/npx
I removed this exectutable and now:
$ which npx
/Users/MY_USER/n/bin/npx
and it works now.
I was getting this error when running npx sb init. For some reason, the command worked localy but not in CI. I tried most of the solutions from here. But only the following worked.
I replaced npx sb init with yarn global add #storybook/cli && yarn exec sb init as suggested here: https://github.com/yarnpkg/yarn/issues/3937#issuecomment-751289438
(NVM, Node.js 14, Yarn 1)
if you are also getting this error:
1 warn npm npm does not support Node.js v16.2.0
that means that your npm version is not correct.
reinstall npm, try again.
It works for me.
Feb 2021 fix:
npm install
And then commit the changes to package-lock.json. That should update all your dependencies, thus fixing this issue.
More info: https://help.heroku.com/ZV7S7D6T/why-is-my-node-build-is-suddenly-displaying-npm-err-cb-apply-is-not-a-function (this happened to me on heroku)
For linux users:
uninstall NPM, to do it go to /usr/local/lib/node_modules and do:
sudo rm -r n npm npx
Once uninstalled, re-instal it:
npm install
Even after doing this, in a specific project when trying to install a specific npm package, you may get the following error:
bash: /usr/local/bin/npm: No such file or directory
If so, in the terminal just run:
hash -r
Now you can retry installation of your wanted npm package.
For me , the solution was to delete the node modules and bower components folder of the project.
for the mac OS remove the node version and reinstalling was work for me. I used n npm version manager.
On windows, using nvm, i just installed a newer nodejs version (before 14.17.0, now 14.18.2)
So many solutions just made me even more puzzled. I downloaded and installed the newest LTS NodeJS and it worked just fine.
https://nodejs.org/en/
I'm on a Mac, and had exactly the same issue. Deleting the node modules seemed a little overkill for me, so I ran npm update and it solved the issue! Please note I did not yet have any package.json or any modules on the repo I was working in.
Windows 10:
When calling npx create-react-app my-app, i got following error:
npm ERR! cb.apply is not a function
To fix it, i did the following:
Go to the folder you want to create the app in.
npm install create-react-app --save-dev
npx create-react-app my-app
The problem has occured when the node and npm packages are not latest.
For me the problem is resolved when I completely removed npm and node, and made a clean installation.
I am using ubuntu 22 lts
to remove node and npm completely I have followed this answer
Had this issue when creating a new react app using create-react-app.
I was using nvm, so I just updated it to the latest LTS version:
nvm install --lts
then switched to the newly installed lts version:
nvm use --lts
closed and reopened the terminal, reran create-react-app and the error was fixed!
Solution for ubuntu =>
Completely remove nodejs and npm from your system.
sudo apt-get remove nodejs
sudo apt-get remove npm
Install node from this reference (https://computingforgeeks.com/install-node-js-14-on-ubuntu-debian-linux/) - This will inturn install latest npm .
Had the same error was simply in the wrong folder -.- (not a typescript project)

spawn yarnpkg ENOENT

This happens when I run expo install expo-permissions
It explicitly returns me
Installing 1 SDK 35.0.0 compatible native module using Yarn.
yarn add expo-permissions#~7.0.0
spawn yarnpkg ENOENT
Set EXPO_DEBUG=true in your env to view the stack trace.
Which is strange because I don't normally use Yarn. I use NPM to install dependencies.
I know this error has to do with my files or some path not being configured correctly. What I don't know is which path it is that I have to change and how to do so.
Please let me know if there is any other relevant info that I should add here.
I had the same problem as you my solution and you perform the installation of yarn via npm:
npm i -g yarn
I believe this error is caused because he cannot find the symbolic link for yarnpkg. When executing this command, yarn will be updated and linked.
You can just pass the flag --npm after the command.
expo install [package-name] --npm
Best solution for this would be using --npm flag
Example:
expo install pkname --npm,
expo update --npm,
expo upgrade --npm,
This is happened because you haven't executed yarn install or yarn command.
Yes, I tried many ways and finally, I found the solution.
The issue was different yarn package version.
So first of all, you need to upgrade yarn version lastest.
open terminal and type the following.
npm install --global yarn
expo update
Hope this solve your issue.
I had a similar problem. You should install yarn in your system, since that's what Expo CLI is trying to execute to install packages. For me my issue was that I did had yarn but I had an old version. I had to update my yarn version to 1.19.0. If you install this version it should work correctly.
I recommend using yvm to install and manage different versions of yarn. After you install yvm it is as easy to install yarn as yvm install <version>, so in this case you would do yvm install 1.19.0. And if you ever have to change versions because another project doesn't work with 1.19.0 (sometimes it happens) you can just install another version and change between versions by doing yvm use <version>.
Hope this helps!
This worked for me:
Latest Yarn Installation (from here)
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
sudo apt update && sudo apt install --no-install-recommends yarn
Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
In the terminal, log in and log out for the changes to take effect
yarn --version checks if the version is latest (1.0+).
Then expo update <version> (ex: 36.0.0)
Concideration:
Do not forget to check if you give attention to similar warning: "warning package-lock.json found. Your project contains lock files generated by tools other than Yarn."
"spawn yarnpkg ENOENT" usually indicates that the system cannot find the "yarnpkg" command.
npm i -g corepack
This worked for me.
For nextjs you can try this as I found out that I am npx not yarn same as how I start npx expo start
npx expo update

The engine "node" is incompatible with this module

I am getting below yarn error when deploying to AWS
error fs-extra#7.0.1: The engine "node" is incompatible with this module. Expected version ">=6 <7 || >=8". Got "7.0.0"
Any idea how will this be resolved?
Will this work out if I specify engine in package.json
{
"engines" : {
"node" : ">=8.0.0"
}
}
You can try to ignore the engines :
$ yarn install --ignore-engines
OR
$ yarn global add <your app> --ignore-engines
You can see all what you can ignore by running:
$ yarn help | grep -- --ignore
--ignore-scripts don't run lifecycle scripts
--ignore-platform ignore platform checks
--ignore-engines ignore engines check
--ignore-optional ignore optional dependencies
You need to upgrade your version of node.
I ran into this same issue.
If you used Homebrew run:
brew update # This updates Homebrew to latest version
brew upgrade node
If you use nvm run:
nvm current node -v # Checks your current version
nvm install <version> # Example: nvm install 12.14.1
For the above step go to https://nodejs.org/en/download/
Grab a version which satisfies the conditionals in your error, the latest version should work.
More Detailed Walkthrough: https://flaviocopes.com/how-to-update-node/
A fix that is a hack can be
yarn config set ignore-engines true
However if you want a permanent solution is to :
delete node_modules/, package-lock.json & yarn.lock
run yarn install or npm i again.
Add --ignore-engines to the suffix while installing the package like this:
yarn add <package_name> --ignore-engines
My problem was solved with yarn --ignore-engines, but I'm not sure why and how.
I had a similar issue on Ubuntu even after installing Nodejs many times with the latest version, it was showing always the same old Nodejs version; I discovered it was installing the similar old Debian package each time, even after executing the apt-get update command
Finally, I got it to work by purging the old nodeJs then adding different repository source, and installing nodeJs normally with the new distribution as follows:
sudo apt-get purge --auto-remove nodejs
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Please find the list of all NodeJs distribution below
https://github.com/nodesource/distributions/blob/master/README.md
You may find other ways of doing the update, but this one worked for me.
I do NOT recommend using this:
% yarn install --ignore-engines
It avoids the issue instead of solving it.
A possible solution would be to update your node to version > 8.0.
% brew upgrade node
Or you could try installing multiple versions of node by using nodenv, in case you need them for other projects.
% brew install nodenv
% nodenv init
# Load nodenv automatically by appending
# the following to ~/.zshrc:
eval "$(nodenv init -)"
% nodenv install 6.0.0 //or some other version
Lots of answers say to set flags to ignore the version error.
A better option is to use this as a reminder to update your node version to something recent and supported by the package you want to install.
nvm install 16.16.0 # download & install locally on your system
nvm use 16.16.0 # update current project's .nvmrc file
Note that the 2nd command will update your local .nvmrc which specifies a per-project node version.
The node ecosystem turns over quickly, even "Long Term Support" (LTS) releases stop getting support after about 3 years. Use this page to see the latest LTS release version, and also make sure it matches the node version expected by the package you're installing, from the error message.
You can try:
Open you package.json
find
"engines": { "node": "14.x" }
change 14.x -> >=14.x
I recommend doing what the error message says and checking your Node.js version (node -v). The easiest way to upgrade Node.js is with the n version manager:
$ npm install -g n
Then install the latest (n latest) or LTS (n lts) version of Node.
What worked for me was to update Node to the latest version. Following any tutorial depending on your OS.
Upgrading Node.js to latest version
sudo npm cache clean -f
sudo npm install -g n
sudo n 10.22.1
node -v => Should be on 10.22.1
type what version of node you require as I have just put 10.22.1 as an example
Update your Node.js to the latest version.
https://nodejs.org/en/download/
you need to run the below command and your problem will be solved
yarn install --ignore-engines
or
npm install --ignore-engines
This is a lot more problematic than it seems on the surface.
If you include a module that requires node 6, but you have other modules that use node 11, you will get this error!
It's problematic when it's 3rd party modules you've used nom/yarn/etc. to install, as you don't have access to those package repos without doing git fork.
In my case, I am using yarn workspaces and some of the modules in the package.json files in the workspaces might require foo 1.0 while others require foo 2.0 and the 1.0 version might require node 6 and the 2.0 version might require node 14.
The only solution I found is to use --ignore-engines, though it clearly is what other(s) have posted - that this is not fixing the problem, just ignoring it in spite of any issues that might be caused (node 6 code might not run on node 14!).
Sometimes you cannot upgrade the Node engine (legacy projects, client requirements etc). The solution I found in this case was to downgrade the problematic versions by using "selective dependency resolution", as documented on Yarn:
https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/
{
"name": "project",
"version": "1.0.0",
"dependencies": {
"left-pad": "1.0.0",
"c": "file:../c-1",
"d2": "file:../d2-1"
},
"resolutions": {
"d2/left-pad": "1.1.1",
"c/**/left-pad": "^1.1.2"
}
}
Notice the "resolutions" part. You can force those packages to downgraded versions (compatible with your older Node engine).
I found this problem now, with an old code, however, I solved it with:
yarn upgrade
Just found that not only I need to upgrade the node, but also need to install it.
This upgrades node to latest version:
brew upgrade node
This install the specific version of node:
nvm install 17.0.0
Upgrade your version of node , this issue will be resolved

Resources