'I can't install npm install --save react-tilt

C:\Users\JohnSam\Desktop\React\smartapp>npm install --save react-tilt
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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@"^15.0.0 || ^16.0.0-beta || ^16.0.0" from [email protected]
npm ERR! node_modules/react-tilt
npm ERR!   react-tilt@"*" 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 C:\Users\Sengk\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Sengk\AppData\Local\npm-cache\_logs\2021-11-30T08_35_11_646Z-debug.log


Solution 1:[1]

The error says that the version of React you are using (17.0.2) is not compatible with react-tilt.

When looking at the package.json file of react-tilt, you'll see it requires a peerdependency of react@^15.0.0 || ^16.0.0-beta || ^16.0.0.

NPM enforces correct peerdependencies by default since npm v7. If you realy want to, you can ignore this check and run npm install --save --legacy-peer-deps react-tilt.

Note that this means there is no guarantee this package will completely work with React 17.

Solution 2:[2]

I am using React 18.1.0 and had the same issue with react-tilt. To fix it I ran this command:

npm install --save --legacy-peer-deps react-tilt

So far it is working ok.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yadejo
Solution 2 JBS