typescriptnext.jsnextjs14

Module not found: Can't resolve 'react-server-dom-webpack/client'


I am using next.js 14 when I try to build the project then I get the following error, but when I run my project locally with npm run dev it works fine.

I stuck here for the last 1 day, I am trying to deploy my project.

repo: https://github.com/vishwas-babar/true-feeback/tree/version2

PS C:\Users\vishw\OneDrive\Desktop\next js\true_feedback> npm run build

> true_feedback@0.1.0 build
> next build

  ▲ Next.js 14.2.14
  - Environments: .env

   Creating an optimized production build ...
Failed to compile.

./node_modules/next/dist/build/webpack/loaders/next-flight-loader/action-client-wrapper.js
Module not found: Can't resolve 'react-server-dom-webpack/client'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/actions/action.ts
./src/components/Signin.tsx
./src/pages/SigninPage.tsx

./node_modules/next/dist/client/components/router-reducer/fetch-server-response.js
Module not found: Can't resolve 'react-server-dom-webpack/client'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/next/dist/client/components/router-reducer/prefetch-cache-utils.js
./node_modules/next/dist/client/components/router-reducer/create-initial-router-state.js
./node_modules/next/dist/client/components/app-router.js
./node_modules/next/dist/client/app-call-server.js
./node_modules/next/dist/build/webpack/loaders/next-flight-loader/action-client-wrapper.js
./src/actions/action.ts
./src/components/Signin.tsx
./src/pages/SigninPage.tsx

./node_modules/next/dist/client/components/router-reducer/reducers/server-action-reducer.js
Module not found: Can't resolve 'react-server-dom-webpack/client'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/next/dist/client/components/router-reducer/router-reducer.js
./node_modules/next/dist/shared/lib/router/action-queue.js
./node_modules/next/dist/client/components/use-reducer-with-devtools.js
./node_modules/next/dist/client/components/app-router.js
./node_modules/next/dist/client/app-call-server.js
./node_modules/next/dist/build/webpack/loaders/next-flight-loader/action-client-wrapper.js
./src/actions/action.ts
./src/components/Signin.tsx
./src/pages/SigninPage.tsx


> Build failed because of webpack errors
PS C:\Users\vishw\OneDrive\Desktop\next js\true_feedback> 

Solution

  • I found a solution for this. in my next app, I used the pages directory inside a src due to this it gave me this error. when I changed the name of the pages directory then this error was solved.