I am working on a react-app. At the moment I have installed react#17.0.0 and I have some plugins which need this version of react. Now I wanted also to use react-canvas, which needs react#15.0.0.
The Warning after installing react-canvas is the following:
npm WARN react-canvas#1.3.0 requires a peer of react#^15.0.0 but none is installed. You must install peer dependencies yourself.
Is it possible to define multiple react versions or something like that? Because I can't downgrade react, because of the other plugins and canvas is only running with react version 15.
Generally you have to wait for the plugin's upgrade to support higher version of react, 16.x, 17.x, then update the peerDeps to be 15 || 16 || 17
But based on the plugin status, looks like this plugins is dead, no update any more.
So if it still works with react, good luck, you can ignore the warning...
Related
I've developed with React for a long time but I've only recently tried my hand at publishing packages.
A dependency of the package I'm working on causes issues if there are conflicting React installations between the package and the project it's being installed into. (The package is react-query)
How do I handle this situation?
Ideally I'd like the two versions to be the same as React 17.x and React 18.x have weird type changes which causes issues when being used together. But I'm honestly completely lost.
Googling doesn't seem to bring up anything I can use.
You should specify react as a peer dependency in your lib package.json file:
"peerDependencies": {
"react": ">= 17"
}
When encountering a peer dependency, npm will check the dependencies of the project that is using your lib:
If these include react matching the version requirements, then nothing else needs to be done
If a suitable version of react was not found, then npm will install the latest matching version
Behavior can be different with older versions of npm and only a warning will be printed in the console during npm install.
Just wanted to know sometimes we have to use older version of react, so could somebody please provide some simple solution
Please provide some simple solution
You can either specify the peer dependencies in package.json, or lookup the peer dependencies based on the react version and then running
npm install [package-name]#[version-number]
for example, if I need to install an old version of prisma, say prisma version 3.2.0, I would have to run the following command in-console:
npm install prisma#3.2.0
I cloned a React/typescript package from GitHub, but cannot get it to work. When I do npm install, the compiler complains that my typescript version is too new:
WARNING: You are currently running a version of TypeScript which is not officially supported by #typescript-eslint/typescript-estree
Is there some way, I can use exactly the node and packages versions as listed in the package.json?
I've also tried npm install --legacy-pee-deps, but that wasn't fruitful either, still get the problem. Also, I tried setting npm config set save-exact true before installing packages.
Thanks!
I have a problem on installing react-redux. I copied and pasted the problem here. Is it reasonable to have 2 versions of react-native at the same time in one project?
react-native says :
WARN react-native#0.59.4 requires a peer of react#16.8.3 but none is installed. You must install peer dependencies yourself.
react-redux says :
WARN react-redux#7.0.1 requires a peer of react#^16.8.4 but none is installed. You must install peer dependencies yourself.
by installing 16.8.3, react-redux will look for 16.8.4. on the other side, react-redux does not work with 16.8.3 and required 16.8.4. How to solve the problem?
Ok, I found the reason. 22 hours ago react-redux has updated to 7.0.1 and as its documentation says :The major change for this release is that connect is now implemented using Hooks internally. Because of this, we now require a minimum React version of 16.8.4 or higher. it requires 16.8.4 at least. So the best solution is now to install react-redux version 6.0.1 by:
npm install --save react-redux#6.0.1
I have installed Jest v17.0.3 in my react project.
When I run jest locally it works fine, but on the build server it fails with:
Error: Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js'
Both machines are running node version 6.9.1 and npm version 4.0.2.
use same version of react and react-dom. My problem fixed after using this command
npm install --save react#15.4.0 react-dom#15.4.0
this problem specially occurs on react 15.4.0 above.
Can you check which version of React you are using? Is it the same on both servers? I would try removing node_modules and reinstalling the dependencies. The reason I am suggesting this is that in React v15.4.0 you cannot import private apis and it seems that ReactDebugTools.js is trying to import from react/lib/....
From the blogpost about React v15.4.0 (Link):
However, there is a possibility that you imported private APIs from react/lib/*, or that a package you rely on might use them. We would like to remind you that this was never supported, and that your apps should not rely on internal APIs. The React internals will keep changing as we work to make React better.
Hope this helps!
In the latest versions of react we often see this error as we have loaded 2 versions of react:
To make sure you have just 1 version, run the following in your terminal:
npm ls react-dom
npm ls react
Both the react and react-dom versions need to be same.
If any one of these returns more than 1 version then that's not supported. You have to then correct it in your corresponding package.json
I had the same issue and i removed the node_modules and ran npm install and it fixed the problem.