I am getting an error trying to install the react-redux package onto my create-react-app application. I have tried deleting and reinstalling my node_modules folder as well as installing it with admin permissions and I am still receiving the same error
➜ frontend git:(main) ✗ npm i react-redux
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
Here is the remaining output from the console
npm ERR!
npm ERR! While resolving: frontend#0.1.0
npm ERR! Found: react#17.0.1
npm ERR! node_modules/react
npm ERR! react#"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.8.3" from react-redux#7.2.1
npm ERR! node_modules/react-redux
npm ERR! react-redux#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Here is the list of current dependencies in my package.json
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^0.21.0",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.4",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"tachyons": "^4.12.0"
},
It looks like you are using the latest npm version (v7).
As mention in the logs, try with
npm install --legacy-peer-deps
The last time npm Blog mentioned the --legacy-peer-deps flag was while their beta version of npm v7 got public. To read more about the flag go here.
Two ways:
npm install <package-name> --legacy-peer-deps
install Recommended node version for most users
The better way is to install the recommended version of node to work for all packages.
Try installing recommended nodejs version(screen shot below). Which should fix this issue.
Here is a recreation of this error and its solution (screenshots below):
Problem:
Nodejs : Latest features:
Solution:
Nodejs : Recommended for most users:
Installing the Recommended version of node js fixed this issue instantly allowing installation of relevant dependancies.
Incase you are facing this issue with a react-native dependency then once you have installed the recommended version be sure to update your pod file.
Try using Node.js latest "Recommended For Most Users" Version .
it worked for me
I had this issue and nothing seemed to work.
I fixed it by downgrading node to version 12.14.1
Uninstall the current node version and install 12.14.1 from this link
Tried for Mac, it worked.. follow the steps for upgrading to the latest LTS
Before updating the Node.js release, check which version you are currently using with:
node -v
Next, clear npm cache with the command:
npm cache clean -f
Install n globally:
npm install -g n
Now that you have n installed, you can use the module to install the latest stable release of Node.js:
sudo n stable
Alternatively, you can install the Node.js release with the latest features:
sudo n latest
Or, install a specific version number with:
n [version.number]
I faced the same issue, so id run this command
npm config set legacy-peer-deps true
Then I simply created my react app using redux template by following
npx create-react-app app-name --template redux
worked for me!!
Its a little bit late but you can resolve this with --force or --legacy-peer-deps options. Either should work as mentioned in the error reported by npm
Try adding it with yarn. Worked for me
Related
TL;DR: What is the fastest way to upgrade a legacy Angular (eg v11) to the latest version (eg v15)?
I have an Angular 11 solution which has this packages.json file:
{
"name": "my-first-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^11.0.5",
"#angular/common": "^11.0.5",
"#angular/compiler": "^11.0.5",
"#angular/core": "^11.0.5",
"#angular/forms": "^11.0.5",
"#angular/platform-browser": "^11.0.5",
"#angular/platform-browser-dynamic": "^11.0.5",
"#angular/router": "^11.0.5",
"bootstrap": "3.3.7",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.0.0",
"tslib": "^2.0.3",
"zone.js": "^0.10.3"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.1100.4",
"#angular/cli": "^11.0.4",
"#angular/compiler-cli": "^11.0.5",
"#types/jasmine": "~3.6.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.19.9",
"codelyzer": "^6.0.1",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}
npm install in the solution folder produces this:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-first-app#0.0.0
npm ERR! Found: jasmine-core#3.6.0
npm ERR! node_modules/jasmine-core
npm ERR! dev jasmine-core#"~3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core#">=3.8" from karma-jasmine-html-reporter#1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR! dev karma-jasmine-html-reporter#"^1.5.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\xxx\AppData\Local\npm-cache\_logs\2023-01-25T20_36_55_645Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxx\AppData\Local\npm-cache\_logs\2023-01-25T20_36_55_645Z-debug-0.log
I then run npm install --legacy-peer-deps, which produces a lot of WARN statements and then shows this:
added 1597 packages, and audited 1598 packages in 1m
118 packages are looking for funding
run `npm fund` for details
27 vulnerabilities (5 moderate, 21 high, 1 critical)
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
So, I run npm audit fix --force which produces this:
added 143 packages, removed 694 packages, changed 122 packages, and audited 1047 packages in 20s
86 packages are looking for funding
run `npm fund` for details
# npm audit report
minimatch <3.0.5
Severity: high
minimatch ReDoS vulnerability - https://github.com/advisories/GHSA-f8q6-p94x-37v3
fix available via `npm audit fix`
node_modules/minimatch
1 high severity vulnerability
To address all issues, run:
npm audit fix
So, I run npm audit fix --force again, and it shows this:
removed 1 package, changed 1 package, and audited 1046 packages in 3s
86 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Now, if I run ng serve I get this:
Your global Angular CLI version (15.0.5) is greater than your local version (11.1.2). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
This version of CLI is only compatible with Angular versions ^15.0.0,
but Angular version 11.2.14 was found instead.
Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/
I visit https://update.angular.io/ and select from v11 to v12, as it also states
You can't run ng update to update Angular applications more than one
major version at a time.
So, from https://update.angular.io/?v=11.0-12.0 I run ng update #angular/core#12 #angular/cli#12, which produces:
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 12.2.18 to perform the update.
√ Packages successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 31 dependencies.
Fetching dependency metadata from registry...
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "#angular/compiler-cli" (requires "^15.0.0" (extended), would install "12.2.17").
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=4.8.2 <5.0", would install "4.3.5").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
See "C:\Users\xxx\AppData\Local\Temp\ng-7soZ7i\angular-errors.log" for further details.
So I run ng update #angular/core#12 #angular/cli#12 --force which produces a lot of output, but appears to work.
Next, I moved to https://update.angular.io/?v=12.0-13.0 which states I should run ng update #angular/core#13 #angular/cli#13 and produces:
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 13.3.10 to perform the update.
√ Packages successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 31 dependencies.
Fetching dependency metadata from registry...
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "#angular/compiler-cli" (requires "^15.0.0" (extended), would install "13.3.12").
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=4.8.2 <5.0", would install "4.6.4").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
See "C:\Users\xxx\AppData\Local\Temp\ng-p47IAP\angular-errors.log" for further details.
So I run it like this: ng update #angular/core#13 #angular/cli#13 --force which also produces a lot of output but finally appears to complete successfully.
This moves me to https://update.angular.io/?v=13.0-14.0 which states I should run ng update #angular/core#14 #angular/cli#14. I see this:
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 14.2.10 to perform the update.
√ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 31 dependencies.
Fetching dependency metadata from registry...
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "#angular/compiler-cli" (requires "^15.0.0" (extended), would install "14.2.12").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
See "C:\Users\xxx\AppData\Local\Temp\ng-wQ5M5Z\angular-errors.log" for further details.
So I run ng update #angular/core#14 #angular/cli#14 --force which, again, appears to complete successfully.
This leads me to https://update.angular.io/?v=14.0-15.0 and running the command ng update #angular/core#15 #angular/cli#15 which appears to complete, as well - fortunately, this time, without the need for --force.
Running ng serve works.
Is this the best way to upgrade a legacy Angular project to the latest version?
Yes, the ng update command is the recommended path to update angular applications.
With the latest CLI Versions, you can update only one version at a time (in the past, you could bump two or more versions at once). The idea behind this is to be able to run all the needed migrations when updating to a newer version without the risk of conflicts. The CLI runs the migrations for you.
The errors you got, like:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-first-app#0.0.0
npm ERR! Found: jasmine-core#3.6.0
npm ERR! node_modules/jasmine-core
npm ERR! dev jasmine-core#"~3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core#">=3.8" from karma-jasmine-html-reporter#1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR! dev karma-jasmine-html-reporter#"^1.5.4" from the root project
Are not related to Angular, but to npm (I guess you are using npm 7+). Newer npm versions will check that peer dependencies versions are respected and throw an error in case of a wrong version (as you are getting). From npm 7 release docs:
npm 7 will block installations if an upstream dependency conflict is
present that cannot be automatically resolved.
You have the option to retry with --force to bypass the conflict or
--legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).
In general, I would advise avoiding using --force while updating your dependencies and trying to find the right combination of versions between the libraries.
I am trying to install material UI as described on the home page, but I get a dependency tree error :
C:\dev\shape-shop-front-end>npm install #mui/material
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app#0.1.0
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.13.1" from the root project
npm ERR! peer react#">=16.8.0" from #emotion/react#11.7.1
npm ERR! node_modules/#emotion/react
npm ERR! node_modules/#mui/material
npm ERR! #mui/material#"*" from the root project
npm ERR!
In my package.json I have "react": "^16.13.1" .
As I understand it, this error is saying that a MUI package needs react 16.8.0
Indeed, a sub-dependency of it, named #emotion/react#11.7.1, has listed the following peer dependencies you have to meet:
"peerDependencies": {
"#babel/core": "^7.0.0",
"react": ">=16.8.0"
}
source: https://github.com/emotion-js/emotion/blob/main/packages/react/package.json
I think this has to do with how new versions of NPM deal with peer dependencies: https://github.blog/2021-02-02-npm-7-is-now-generally-available/
As your react version seems OK, I would go with this suggestion:
You have the option to retry with --force to bypass the conflict or --legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).
Try using --force.
That's what worked for me
npm install #mui/material --force
I have a feeling it's a dependency conflict that came with the recent React upgrade...
Looks like updating dependencies in package.json is the only way to make this happen now.
$ npm install -g npm-check-updates
$ ncu -u
$ npm install
or see how to update each dependency in package.json
after updating, now try to install your material UI.
use this command instead
npm install #material-ui/core
If you're using it for the icon, then use this
npm install #material-ui/core #material-ui/icons
Try using
npm install #material-ui/core --force
This question already has answers here:
create-react-app dependency version issues with React 18
(6 answers)
Closed 10 months ago.
Even --force or --legacy-peer-deps didn't work.
Transcript:
npx create-react-app my-app
Creating a new React app in /home/zahid/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1353 packages in 2m
171 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app#0.1.0
npm ERR! Found: react#18.0.0
npm ERR! node_modules/react
npm ERR! react#"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"<18.0.0" from #testing-library/react#12.1.5
npm ERR! node_modules/#testing-library/react
npm ERR! #testing-library/react#"^12.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/zahid/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/zahid/.npm/_logs/2022-04-11T22_25_02_229Z-debug-0.log
npm install --no-audit --save #testing-library/jest-dom#^5.14.1 #testing-library/react#^12.0.0 #testing-library/user-event#^13.2.1 web-vitals#^2.1.0 failed
This is going to solve the problem:
npm config set legacy-peer-deps true
Explanation:
The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer dependencies and proceed with the installation anyway. This is how things used to be with NPM v4 through v6.
npx create-react-app my-app
npm config set legacy-peer-deps true
Executing that helped me (on Linux).
Here is what worked for me:
Run npx create-react-app as normal and got the errors
Go into the package.json file and change the React version from 18.0.0 to 17.0.0
Delete the node_modules folder.
Then run npm install.
No more errors.
This works for me
I changed this in my package.json (I downgraded the versions):
"react": "^18.0.0",
"react-dom": "^18.0.0",
To
"react": "^17.0.0",
"react-dom": "^17.0.0",
Then, remember to remove your folder /nodes_modules and run this in your project main folder:
npm i
Try to run this first:
npm config set legacy-peer-deps true
And try your command again.
It worked with me!
Try to run this command first:
npm config set legacy-peer-deps true
and then type the command
npx create-react-app app-name
It worked for me.
Try this:
Delete folder node_modules and file package-lock.json
Go to file package.json and change both react and react-dom's version to 17.0.0
Now run npm install
Things should now work as expected.
With an AngularJS application I installed npm --> npm install. I get the 6.4.1 version, but when I typed npm audit or npm fix audit to fix some issues, I have this message showing bellow :
λ npm audit
npm ERR! code ELOCKVERIFY
npm ERR! Errors were found in your package-lock.json, run npm install to fix them.
npm ERR! Missing: gulp-sass#^2.0.4
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\iamari\AppData\Roaming\npm-cache\_logs\2019-02-20T10_16_09_010Z-debug.log
Then, I tried to fixed with npm install gulp-sass or npm i gulp-sass. I get "gulp-sass": "^2.0.4", on package.json file. But I have same errors mentionned previously.
Any solution please?
Maybe you could try removing your package-lock.json and then reinstalling gulp-sass:
rm -f package-lock.json
npm i gulp-sass
It looks like you may have a lockfile conflict.
Hopefully that helps!
Note: I have latest npm and node versions. I have tried the answers provided in npm install error ENOTDIR but didn't work for me.
I need to install 2 npm modules got as .tgz packages on NodeRed
1. x.tgz
2. y.tgz
I could install the first package using npm install path/to/x.tgz
I used the same command npm install path/to/y.tgz command but I am getting following error.
malintha#malintha-VirtualBox:~/.node-red$ sudo npm install path/to/y.tgz
npm ERR! path path/to/y.tgz/x.tgz
npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall stat
npm ERR! ENOTDIR: not a directory, stat 'path/to/y.tgz/x.tgz'
According to the error log, y module is looking for x.tgz inside it. Then I checked the package.json of y.tgz artefact.
I can see it has x.tgz as the dependency inside it, but it don't have x.tgz inside it.
"dependencies": {
"#abc/pqr": "file:x.tgz",
"ajv": "^6.5.1",
"debug": "^3.1.0"
}
According to the instructions, it should be fine if I install the x.tgz and then y.tgz. I could install these x and y some time back but now I cannot install it.
What might be the root cause for this issue?
Is this npm and node versions related issue?
I'm re-writing this answer after deleting my old answer. I tested it with and node v11.6.0 and npm v4.5.0-next.0 on Linux.
To install y.tgz, I tried as below:
I copied both tgz files in the same directory.
I modified package.json of y.tgz as below:
"dependencies": {
"#abc/pqr": "file:../x.tgz",
"ajv": "^6.5.1",
"debug": "^3.1.0"
}
dependencies supports file: + relative path or absolute path.
So, you can choose anyone as your development condition.