JaeLeeSo
JaeLeeSo

Reputation: 263

Unable to update React and React Native with npm

I am trying to update to [email protected] and [email protected] but I am running into the following error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"16.13.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from [email protected]
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.64.0-rc.0" 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 am currently on React 16.13.1 and React Native 0.63.4. Any idea on how to resolve this?

Just ran it with --verbose and got this as well:

npm notice 
npm verb stack Error: unable to resolve dependency tree
npm verb stack     at Arborist.[failPeerConflict] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1143:25)
npm verb stack     at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1242:32)
npm verb stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:851:46
npm verb stack     at Array.map (<anonymous>)
npm verb stack     at Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:851:8)
npm verb stack     at processTicksAndRejections (node:internal/process/task_queues:94:5)
npm verb stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:209:7)
npm verb stack     at async Promise.all (index 1)
npm verb stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
npm verb stack     at async Install.install (/usr/local/lib/node_modules/npm/lib/install.js:120:5)
npm verb cwd /Users/x/Development/App
npm verb Darwin 20.3.0
npm verb argv "/usr/local/Cellar/node/15.9.0/bin/node" "/usr/local/bin/npm" "install" "[email protected]" "--verbose"
npm verb node v15.9.0
npm verb npm  v7.6.2

Upvotes: 3

Views: 1521

Answers (1)

Trott
Trott

Reputation: 70055

You are probably running npm version 7. If so, try running your npm install commands with --legacy-peer-deps.

npm version 6 had a relatively lax approach to dependency conflicts, and npm version 7 is more strict, so will fail in situations where npm 6 did not. To go back to the npm 6 dependency resolution algorithm, use the --legacy-peer-deps flag. Another option would be to downgrade to npm 6.

Upvotes: 6

Related Questions