UNMET PEER DEPENDENCY react - reactjs

I have errors when want to install npm install node-saas
├── UNMET PEER DEPENDENCY react#15.4.2
└── UNMET PEER DEPENDENCY react-dom#15.4.2
npm ERR! peer dep missing: react#^0.14.1, required by
react-select#0.9.1
npm ERR! peer dep missing: react-dom#^0.14.1, required by
react-select#0.9.1
npm ERR! code 1
Please help, Thank you very much.

I think you forgot to install react and react-dom, first run this command it will install react and react-dom properly with all dependencies, after that run other commands.
npm install react react-dom --save
By using --save it will make a entry in package.json file, after using above command check your package.json file, these entries will be there:
"react": "^XX.X.X",
"react-dom": "^XX.X.X",

Related

Why npm install keeps giving dependency error?

While running npm install i got the following error:
While resolving: material-app#3.0.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14.9 || ^15.3.0 || ^16.0.0" from react-quill#1.3.5
npm ERR! node_modules/react-quill
npm ERR! dev react-quill#"1.3.5" 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.
I tried removing package-json and deleting node modules and reinstalling them but still couldn't solve it. Please give me suggestion on how to fix it.
It seems react-quill 1.3.5 uses React ^16.0.0 and not React ^17.0.0 as a dependency while you are running React v17.
From this other post :
Due to the large number of modules that haven't specifically added React v17 as a peerDependency, it's now commonplace to encounter the unable to resolve dependency tree error when running npm installs within a v17 React application.
This error will fire whenever a module (or any of its own dependencies) lists a previous version of React as a peerDependency without specifically including React v17 as well.
The newer version of react-quill (v2.0.0-beta) is using React v17 so one option would be to install it.
npm install react-quill#beta
See repository issue
You have a dependency tree conflict.
Follow this:
Delete Packagelock.json
Delete Node Modules.
Update the version of react -quill in package.json to react-quill#beta OR Update the version of react-quill to beta as it supports react 17 using npm update react-quill#beta
Run npm i adn then npm start

could not create react project

I was trying to create a react project using the command
npx create-react-app chat-app
But I am getting this error.
Creating a new React app in /home/mikhil/react-tutorial/internshala-react-course/chat-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! npm ERR! Found: #babel/core#undefined
npm ERR! node_modules/#babel/core npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer #babel/core#"^7.0.0-0" from #babel/preset-env#7.13.10
npm ERR! node_modules/#babel/preset-env
npm ERR! #babel/preset-env#"^7.12.1" from #svgr/webpack#5.5.0
npm ERR! node_modules/#svgr/webpack
npm ERR! #svgr/webpack#"5.5.0" from react-scripts#4.0.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts#"*" 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/mikhil/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mikhil/.npm/_logs/2021-03-18T11_58_50_255Z-debug.log
Aborting installation. npm install --save --save-exact --loglevel
error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting chat-app/ from /home/mikhil/react-tutorial/internshala-react-course
Done.
You can try to update npm with npm update and see if that fixes it, and if not you can try these steps.
If you've previously installed create-react-app globally via npm install -g create-react-app, it is recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.
You will also want to delete your remnant files and folders for chat-app
Once you are in the /home/mikhil/react-tutorial/internshala-react-course directory and you have removed the global installations you can try running these commands.
npx create-react-app my-app
cd my-app
npm start
Create React App - Getting Started
I was having the same issue with NPM version 7.20.0.
Simply install an older version of NPM.
In the terminal run: npm install npm#6.14.11 -g
There appears to be some particular versions of NPM that cause this issue. Try updating to the very latest version of NPM.
I was also trying to do the same the whole day, then at last I have to open the documentation, there it was mentioned that you can also create react app using
npm init create-react-app **app_name**
and it worked for me fine.
I was troubled very much by this dependency thing.

npm peer dependencies for react-helmet-async package gives error using React 17

For a React 17 project, bootstrapped with create-react-app, I want to use the react-helmet-async package.
This project has the following peer dependencies, located in the package.json file:
"peerDependencies": {
"react": "^16.6.0",
"react-dom": "^16.6.0"
},
When trying to install the package, the following error appears:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project#1.0.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.6.0" from react-helmet-async#1.0.7
npm ERR! node_modules/react-helmet-async
npm ERR! react-helmet-async#"^1.0.7" 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/bas/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/bas/.npm/_logs/2021-02-11T13_55_56_813Z-debug.log
As far as I understand, the react-helmet-async package requires React ^16.6.0 for projects using this package. I can use the --force option, which removes the error, but when I try to do an npm update it keeps recurring.
I tried adding resolutions in my package.json, trying to force the package to use the React version I'm using. Before running a npm install or npm update, I ran npx npm-force-resolutions.
"resolutions": {
"react-helmet-async/react": "^17.0.1"
}
This unfortuntaly did not work. Is there any way, without downgrading to React 16, to still use this package without receiving errors in my console? Also, am I misunderstanding something about peer dependencies?
As far as the peer dependency of react#^16 I ran out of luck other then using the --force option when installing the package. However a commit in a new version of react-helmet-async fixed the problem.

NPM transitive dependencies do not work for Angular [duplicate]

For example, when I install Angular2:
npm install --save angular2
temp#1.0.0 /Users/doug/Projects/dougludlow/temp
├── angular2#2.0.0-beta.3
├── UNMET PEER DEPENDENCY es6-promise#^3.0.2
├── UNMET PEER DEPENDENCY es6-shim#^0.33.3
├── UNMET PEER DEPENDENCY reflect-metadata#0.1.2
├── UNMET PEER DEPENDENCY rxjs#5.0.0-beta.0
└── UNMET PEER DEPENDENCY zone.js#0.5.11
npm WARN angular2#2.0.0-beta.3 requires a peer of es6-promise#^3.0.2 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of es6-shim#^0.33.3 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of reflect-metadata#0.1.2 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of rxjs#5.0.0-beta.0 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of zone.js#0.5.11 but none was installed.
Is there a magic flag that I can pass to npm that will install the peer dependencies as well? I haven't been able to find one... It's tedious to manually copy and paste the peer dependencies and make sure I have the correct versions.
In other words, I'd rather not have to do:
npm install --save angular2#2.0.0-beta.3 es6-promise#^3.0.2 es6-shim#^0.33.3 reflect-metadata#0.1.2 rxjs#5.0.0-beta.0 zone.js#0.5.11
What is the better way?
npm version 7 and newer
npm v7 has reintroduced the automatic peerDependencies installation. Now in V7, as in versions before V3, you only need to do an npm i and all peerDependences should be automatically installed.
They had made some changes to fix old problems as version compatibility across multiple dependants.
You can see the discussion and the announcement.
Older Answer
The automatic install of peer dependencies was explicitly removed with npm 3, as it cause more problems than it tried to solve. You can read about it here for example:
https://blog.npmjs.org/post/110924823920/npm-weekly-5
https://github.com/npm/npm/releases/tag/v3.0.0
So no, for the reasons given, you cannot install them automatically with npm 3 upwards.
I solved it by rewriting package.json with the exact values warnings were about.
Warnings when running npm:
npm WARN angular2#2.0.0-beta.3 requires a peer of es6-shim#^0.33.3 but none was installed.
npm WARN angular2#2.0.0-beta.3 requires a peer of reflect-metadata#0.1.2
In package.json, write
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
Then, delete node_modules directory.
Finally, run the command below:
npm install
Cheat code helpful in this scenario and some others...
├── UNMET PEER DEPENDENCY #angular/common#4.0.2
├── UNMET PEER DEPENDENCY #angular/compiler#4.0.2
├── UNMET PEER DEPENDENCY #angular/compiler-cli#4.0.2
├── UNMET PEER DEPENDENCY #angular/core#4.0.2
├── UNMET PEER DEPENDENCY #angular/forms#4.0.2
├── UNMET PEER DEPENDENCY #angular/http#4.0.2
├── UNMET PEER DEPENDENCY #angular/platform-browser#4.0.2
├── UNMET PEER DEPENDENCY #angular/platform-browser-dynamic#4.0.2 >
copy & paste your error into your code editor.
Highlight an unwanted part with your curser. In this case ├── UNMET PEER DEPENDENCY
Press command + d a bunch of times.
Press delete twice. (Press space if you accidentally highlighted ├── UNMET PEER DEPENDENCY )
Press up once. Add npm install
Press down once. Add --save
Copy your stuff back into the cli and run
npm install #angular/common#4.0.2 #angular/compiler#4.0.2 #angular/compiler-cli#4.0.2 #angular/core#4.0.2 #angular/forms#4.0.2 #angular/http#4.0.2 #angular/platform-browser#4.0.2 #angular/platform-browser-dynamic#4.0.2 --save
I experienced these errors when I was developing an npm package that had peerDependencies. I had to ensure that any peerDependencies were also listed as devDependencies. The project would not automatically use the globally installed packages.
The project npm-install-peers will detect peers and install them.
As of v1.0.1 it doesn't support writing back to the package.json automatically, which would essentially solve our need here.
Please add your support to issue in flight: https://github.com/spatie/npm-install-peers/issues/4
I was facing the same issue, lucky I found an alternative way to install peer dependencies along with the install command.
Step 1: $ npm i npm-install-peers -D
for more clarity about the plugin: https://www.npmjs.com/package/npm-install-peers
Step 2: Update package.json for magical script
....
"scripts": {
...
"postinstall": "npm-install-peers"
},
....
Step 3: Just need to hit the install command to get installed all plugins
$ npm install
Install yarn and then run:
yarn global add install-peerdeps

Error Installing React

Whenever I do a npm init then npm install react - I get this error
── UNMET PEER DEPENDENCY react#15.3.0
npm WARN baobab-react#0.1.1 requires a peer of react#>=0.13.0 <1.0.0 but none was installed.
npm WARN fixed-data-table#0.4.7 requires a
peer of react#>=0.13.0 <0.15.0 || ^0.14.0-beta3 but none was
installed.
npm WARN react-native#0.30.0 requires a peer of
react#~15.2.0 but none was installed.
npm WARN react-router#0.13.5
requires a peer of react#0.13.x||0.14.x but none was installed. npm
ERR! code 1
This is my node v6.3.0 annd npm 3.10.3 versions.
npm install react --no-optional
Inside your project directory, can you please first run the following commands:-
1) rm -rf node_modules
2) Try installig react again now and other packages which are in your package.json file.

Resources