Next.js Discord

Discord Forum

Nextjs 14.0.0 failed to compile without giving much errors.

Answered
Yellow croaker posted this in #help-forum
Open in Discord
Yellow croakerOP
Hello so when i run npm run build my nextjs 14 app fails the building for some reason.
What basically happens, my terminal fastly shows alot of letters and then it tells me that build failed with this error:

^^^^^^
    `----

Caused by:
    0: failed to parse input file
    1: Syntax Error


> Build failed because of webpack errors


And --verbose give this

                                                     ^^^^^^
    `----

Caused by:
    0: failed to parse input file
    1: Syntax Error


> Build failed because of webpack errors
npm verbose cwd /home/nicholas/Code/resumebuilder/frontend
npm verbose os Linux 6.5.0-41-generic
npm verbose node v22.4.0
npm verbose npm  v10.8.1
npm verbose exit 1
npm verbose code 1


My next.config.js looks this:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  eslint: {
    ignoreDuringBuilds: true,
  },
  experimental: {
    webpackBuildWorker: true, // Enable the Webpack build worker
    optimizePackageImports: ['@mantine/core', '@mantine/hooks'],
  },
  webpack: (config) => {
    config.resolve.alias.canvas = false;

    return config;
  },
  typescript: {
  },
  images: {
    remotePatterns: [
      {

      },
    ],
  },
};

module.exports = nextConfig;

My project were able to build earlier but this is now new problem, and cant figure out what is causing this.
Answered by Yellow croaker
Found out that the problem seem to be on nextjs:

https://github.com/wojtekmaj/react-pdf/issues/1824

So downgraded to 8.0.2 for now with react-pdf
View full answer

5 Replies

Yellow croakerOP
Seems that when i try to build it in vercel it says this:

Detected Next.js version: 14.2.4
Detected `package-lock.json` generated by npm 7+
Running "npm run build"


And my next at package.json is:

   "next": "^14.0.0",
Yellow croakerOP
The problem is that, i dont get any message or any information what is causing this build failure.
Yellow croakerOP
Okey used terminal, instead of the VSC terminal which were not showing the error message.

But to be real there is too much text to find anything, just some compile stuff and in the end:

Build failed because of webpack errors
Yellow croakerOP
In next js 14.0.1 the error seem to be printed if it's related:

./app/components/PDFViewer.tsx
Module not found: Can't resolve 'pdfjs-dist/build/pdf.worker.min.mjs'

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

Import trace for requested module:
./app/components/ResumeBuilder.tsx

./app/components/PdfThumbNail.tsx
Module not found: Can't resolve 'pdfjs-dist/build/pdf.worker.min.mjs'

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

Import trace for requested module:
./app/components/DocumenTabs.tsx


But in 14.2.4 it seem to just compile it and hitting with the error then.

Here is the pdfjs dist:
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
  'pdfjs-dist/build/pdf.worker.min.mjs',
  import.meta.url,
).toString();


package.json:

"@react-pdf/renderer": "^3.4.4",
Yellow croakerOP
Found out that the problem seem to be on nextjs:

https://github.com/wojtekmaj/react-pdf/issues/1824

So downgraded to 8.0.2 for now with react-pdf
Answer