Eugene Tan
Eugene Tan

Reputation: 37

Peer Dependency error while deploying to Vercel

I am trying to deploy my NextJS application onto Vercel but each time at the deploy stage, I am met with these errors and the deployment will fail:

Previous build cache not available
Cloning completed: 426.52ms
Running "vercel build"
Vercel CLI 28.6.0
Installing dependencies...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"18.2.0" from the root project
npm ERR!   peer react@"^18.2.0" from [email protected]
npm ERR!   node_modules/next
npm ERR!     next@"13.0.5" from the root project
npm ERR!   3 more (react-dom, react-icons, styled-jsx)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0" from [email protected]
npm ERR! node_modules/react-typed
npm ERR!   react-typed@"^1.2.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^16.3.0" from [email protected]
npm ERR!   node_modules/react-typed
npm ERR!     react-typed@"^1.2.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.
npm ERR! 
npm ERR! See /vercel/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /vercel/.npm/_logs/2022-12-02T16_42_09_037Z-debug-0.log
Error: Command "npm install" exited with 1

I have tried running npm install --legacy-peer-deps and tried redeploying onto Vercel, but the same issue persists. When I run this application on my localhost:3000 using npm run dev, the application renders fine. Anyone knows what I can do?

I have tried

npm install --legacy-peer-deps

and also pushing these changes onto my GitHub repository. When redeploying, the same issue still shows. I run

npm install --legacy-peer-deps

again, but this time, there are no more changes to be made.

Upvotes: 0

Views: 2822

Answers (2)

Alexis Salcedo
Alexis Salcedo

Reputation: 1

Try deleting your package-lock.json and deploy again.

Upvotes: -1

mocherfaoui
mocherfaoui

Reputation: 1227

you can override the installing command used by Vercel CLI, either by:

  1. Going to Vercel Dashboard -> -> Settings -> General -> Scroll to Build & Development Settings and put npm install --legacy-peer-deps in Install Command
  2. Creating vercel.json file in the root directory of your project that should contain:
// vercel.json
{
  "installCommand": "npm install --legacy-peer-deps"
}

after that push and wait for deployment, it should go through this time

But I recommend looking for the cause of this issue. It seems like some dependency you're using is depending on react-typed, and the latter is not maintained anymore. It's better to seek an alternative

Upvotes: 5

Related Questions