Question

Next Js build failed due to dependency error

In trying to deploy my Nextjs app: I got the following err:

Installing node_modules using npm (from package-lock.json)
[2022-07-25 10:17:14] Running npm ci
[2022-07-25 10:17:14] 
[2022-07-25 10:17:16] npm notice 
[2022-07-25 10:17:16] npm notice New minor version of npm available! 8.11.0 -> 8.15.0
[2022-07-25 10:17:16] npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.15.0>
[2022-07-25 10:17:16] npm notice Run `npm install -g npm@8.15.0` to update!
[2022-07-25 10:17:16] npm notice 
[2022-07-25 10:17:16] npm ERR! code ERESOLVE
[2022-07-25 10:17:16] npm ERR! ERESOLVE could not resolve
[2022-07-25 10:17:16] npm ERR! 
[2022-07-25 10:17:16] npm ERR! While resolving: react-beautiful-dnd@13.1.0
[2022-07-25 10:17:16] npm ERR! Found: react@18.1.0
[2022-07-25 10:17:16] npm ERR! node_modules/react
[2022-07-25 10:17:16] npm ERR!   react@"18.1.0" from the root project
[2022-07-25 10:17:16] npm ERR!   peer react@">=16.8.0" from @emotion/react@11.9.3
[2022-07-25 10:17:16] npm ERR!   node_modules/@emotion/react
[2022-07-25 10:17:16] npm ERR!     @emotion/react@"^11.8.1" from react-select@5.3.2
[2022-07-25 10:17:16] npm ERR!     node_modules/react-select
[2022-07-25 10:17:16] npm ERR!       react-select@"^5.3.2" from the root project
[2022-07-25 10:17:16] npm ERR!   38 more (@floating-ui/react-dom, @reduxjs/toolkit, ...)
[2022-07-25 10:17:16] npm ERR! 
[2022-07-25 10:17:16] npm ERR! Could not resolve dependency:
[2022-07-25 10:17:16] npm ERR! peer react@"^16.8.5 || ^17.0.0" from react-beautiful-dnd@13.1.0
[2022-07-25 10:17:16] npm ERR! node_modules/react-beautiful-dnd
[2022-07-25 10:17:16] npm ERR!   react-beautiful-dnd@"^13.1.0" from the root project
[2022-07-25 10:17:16] npm ERR! 
[2022-07-25 10:17:16] npm ERR! Conflicting peer dependency: react@17.0.2
[2022-07-25 10:17:16] npm ERR! node_modules/react
[2022-07-25 10:17:16] npm ERR!   peer react@"^16.8.5 || ^17.0.0" from react-beautiful-dnd@13.1.0
[2022-07-25 10:17:16] npm ERR!   node_modules/react-beautiful-dnd
[2022-07-25 10:17:16] npm ERR!     react-beautiful-dnd@"^13.1.0" from the root project
[2022-07-25 10:17:16] npm ERR! 
[2022-07-25 10:17:16] npm ERR! Fix the upstream dependency conflict, or retry
[2022-07-25 10:17:16] npm ERR! this command with --force, or --legacy-peer-deps
[2022-07-25 10:17:16] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[2022-07-25 10:17:16] npm ERR! 
[2022-07-25 10:17:16] npm ERR! See /home/apps/.npm/eresolve-report.txt for a full report.
[2022-07-25 10:17:16] 
[2022-07-25 10:17:16] npm ERR! A complete log of this run can be found in:
[2022-07-25 10:17:16] npm ERR!     /home/apps/.npm/_logs/2022-07-25T10_17_14_724Z-debug-0.log
[2022-07-25 10:17:16] 
[2022-07-25 10:17:16] unable to invoke layer creator
[2022-07-25 10:17:16] installing node_modules: exit status 1
[2022-07-25 10:17:16] ERROR: failed to build: exit status 1
[2022-07-25 10:17:18] 
[2022-07-25 10:17:18] For documentation on the buildpacks used to build your app, please see:
[2022-07-25 10:17:18] 
[2022-07-25 10:17:18]    Node.js  v0.3.4  https://do.co/apps-buildpack-node
[2022-07-25 10:17:18] 
[2022-07-25 10:17:18]  ! Build failed
[]

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
August 28, 2022

Hi there,

I believe that the react-beautiful-dnd package is still not compatible with React 18.x.

As a quick fix you can downgrade to React 17 and it should work as normal. In your package.json change your React and react-dom version as follows:

"react": "^17.0.2",
"react-dom": "^17.0.2",

There is already an issue reported about it on the official react dnd repository here:

https://github.com/atlassian/react-beautiful-dnd/issues/2408

Best,

Bobby