相关文章推荐
坚强的南瓜  ·  Day ...·  1 月前    · 
成熟的梨子  ·  React ...·  1 月前    · 
怕老婆的勺子  ·  Azure 文件 REST API | ...·  2 年前    · 
豁达的帽子  ·  Springboot2.x的webflux做 ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams "@testing-/jest-dom": "^5.11.9", "@testing-/react": "^11.2.3", "@testing-/user-event": "^12.6.2", "bootstrap": "^4.6.0", "react": "^17.0.1", "react-dom": "^17.0.1", "react-scripts": "4.0.1", "react-transition-group": "^4.4.1",

versions of dependencies I have in package.json file.

G:\Projects\React\confusion> npm install --save reactstrap

npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react@17.0.1
npm WARN node_modules/react
npm WARN peer react@" " from @testing-/react@11.2.3
npm WARN node_modules/@testing-/react
npm WARN @testing-/react@"^11.2.3" from the root project
npm WARN 3 more (react-dom, the root project, reactstrap)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"0.14.x || ^15.0.0 || ^16.0.0" from react-popper@1.3.7
npm WARN node_modules/react-popper
npm WARN react-popper@"^1.3.6" from reactstrap@8.9.0
npm WARN node_modules/reactstrap
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! peer react@"
" from @testing-/react@11.2.3
npm ERR! node_modules/@testing-/react
npm ERR! @testing-/react@"^11.2.3" from the root project
npm ERR! peer react@"17.0.1" from react-dom@17.0.1
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@" " from @testing-/react@11.2.3
npm ERR! node_modules/@testing-/react
npm ERR! @testing-/react@"^11.2.3" from the root project
npm ERR! react-dom@"^17.0.1" from the root project
npm ERR! 1 more (reactstrap)
npm ERR! 2 more (the root project, reactstrap)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from create-react-context@0.3.0
npm ERR! node_modules/react-popper/node_modules/create-react-context
npm ERR! create-react-context@"^0.3.0" from react-popper@1.3.7
npm ERR! node_modules/react-popper
npm ERR! node_modules/reactstrap
npm ERR! reactstrap@"
" 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.

This is because of a change in npm version 7. See the breaking changes section here . You can fix it by using the flag the error tells you to use at the bottom: npm i reactstrap --legacy-peer-deps . If one of your other dependencies already has reactstrap as a peer dependency, you might not need to install it at all (you can check with npm ls reactstrap ), due to the change in v7.

This will force react to be the version defined in your "dependencies" for all dependencies (& deps of deps). You need "recent" npm as it was buggy in some version (I had 8.3.0 and overrides wasn't working). 8.7.0 seems ok !

See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

Using latest version of npm 8.19.1 and still getting npm ERR! Unable to resolve reference $react i have double checked that react exists on dependencies but still the same error . GOXR3PLUS Oct 3, 2022 at 21:13 I am not sure why, but in some project I explicitly mentioned the version instead of using ${package}.... MoOx Oct 5, 2022 at 10:31

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .