Conflicting peer dependency: [email protected]
I'm getting this error when trying to use the package.
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/typescript
npm ERR! peerOptional typescript@"^3.2.1" from [email protected]
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"3.4.3" from the root project
npm ERR! peer react-scripts@">=2.1.3" from [email protected]
npm ERR! node_modules/react-app-rewired
npm ERR! dev react-app-rewired@"^2.1.6" from the root project
How can I properly install this? I have tried using --force and this doesn't work either.
maybe npm i --legacy-peer-deps should works. This command will ignore the peer dependencies. By default, now npm is installing and validating peer deps
A better way is to use the "overrides" property of package.json. See https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides
For example, I have "typescript": "^5.1.6" in devDependencies and then I have a top level package.json property
"overrides": {
"typescript": "$typescript"
},
The dollar notation means it uses the exact value as specified in devDependencies - "overrides" only works if the version in "overrides" is exactly(!) the same as the one specified elsewhere. So having a version in "dependencies" or in "devDependencies", but then a "*" in "overrides" would be ignored, for example.