I’m having an issue with deploying my React application on Vercel. The build process keeps failing with the following error:
Module not found: Error: Can’t resolve ‘react-dom/client’ in ‘/vercel/path0/src’
Context:
React Version: 17.0.2
React-Scripts Version: 4.0.3
Build Tool: Vercel
Dependencies:
My package.json includes:
{
"name": "book-tracker",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^17.0.2",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.3",
"styled-components": "^5.3.10",
"web-vitals": "^4.2.3"
},
"scripts": {
"start": "react-scripts start",
"build": "CI=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
-
I’ve added @babel/plugin-proposal-private-property-in-object to devDependencies.
-
I ensured I was using Node.js version 16 by configuring it locally using nvm.
-
Asked chatGPT 4-o, which has been completely unhelpful
-
restarted my computer and reinstalled everything
Issue:
The deployment works perfectly fine locally, but on Vercel, it fails with the error above. I’ve ensured that all necessary dependencies are installed and configured.
Question:
Has anyone else encountered this issue, and if so, how did you resolve it? Any guidance or tips would be greatly appreciated!