Next.js Discord

Discord Forum

NextJS build error in github actions. Module not found, build failed due to webpack error

Unanswered
Mourning Dove posted this in #help-forum
Open in Discord
Mourning DoveOP
I've been trying to deploy my NextJS website to Azure App service, via github actions. But I keep getting this error at the build stage.

▲ Next.js 14.2.22

Creating an optimized *** build ...
Failed to compile.
./src/app/(pages)/(admin)/admin/events/[eventId]/edit/page.tsx
Module not found: Can't resolve '@/validation/event'
https://nextjs.org/docs/messages/module-not-found
./src/app/(pages)/(admin)/admin/events/add/page.tsx
Module not found: Can't resolve '@/validation/event'
https://nextjs.org/docs/messages/module-not-found
./src/app/(pages)/(admin)/admin/orders/[orderId]/page.tsx
Module not found: Can't resolve '@/app/components/checkout/checkoutProduct/checkoutProduct'
https://nextjs.org/docs/messages/module-not-found
./src/app/(pages)/(admin)/admin/products/[productId]/edit/page.tsx
Module not found: Can't resolve '@/validation/product'
https://nextjs.org/docs/messages/module-not-found
./src/app/(pages)/(admin)/admin/products/add/page.tsx
Module not found: Can't resolve '@/validation/product'
https://nextjs.org/docs/messages/module-not-found
> Build failed because of webpack errors
Error: Process completed with exit code 1.


I've defined my alias correctly in tsconfig file
{
....
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"],
    }
  },
...
}



My nextjs Config file
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
  distDir: 'build',
  output: 'standalone',
};

export default nextConfig;


I've searched around and couldn't find anything useful for my case. Please help me resolve this issue

I've tried updating the node version in the workflow file to the exact node version that I'm running locally. I've also tried enabling webpack5 in the next config file, which didn't help either.

I'd want the build step to work and complete successfully.

5 Replies

Mourning DoveOP
Can someone please help me with this issue?
Field Spaniel
what happens when you build locally?
Mourning DoveOP
Locally I don't get any errors. The build completes successfully.
@Field Spaniel what happens when you build locally?
Mourning DoveOP
The issue is not resolved yet. Anything that I can do to fix it?
Field Spaniel
hi, could you solve the issue with the build?
I think (not sure) it might have something to do with the TS config
https://www.typescriptlang.org/tsconfig/#moduleResolution