This is my first ever Next.js project, and I encountered an odd obstacle. Even though I made sure at least 3 times that I have react-dom and react installed and up-to-date, during next
, next build
or next run
the process aborts with the message:
The module 'react-dom' was not found. Next.js requires that you include it in the 'dependencies' of your 'package.json'. To add it, run 'npm install --save react-dom'
,
Error: Cannot find module 'react-dom/server'
,
and:
Error: > Build failed because of webpack errors
.
Reading on similar problems, I did a couple of things suggested that actually fit my problem, like removing node_modules
and doing yarn
, reinstalling react-dom
and react
, but none of these helped. Deploying on Now.sh (on which I'm planning to deploy this site) also returns with an error.
This is my package.json
:
{
"dependencies": {
"next": "^9.0.2",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
}
}
I really made sure the result should be the browser opening my project on localhost:3000
, but all of the Next.js commands that could make or lead to making this happen abort. Any ideas? Don't hesitate to ask for more code.
react-dom
undernode_modules
? I assumed your file imports other libraries other thanreact-dom
. Is this the only library that you got this error? – Misanthropynode_modules
directory;react-dom
's definitely there. @GaëlS my folder structure – Misadventure