Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New project npx next build error #72878

Open
RobertKoval opened this issue Nov 16, 2024 · 6 comments
Open

New project npx next build error #72878

RobertKoval opened this issue Nov 16, 2024 · 6 comments
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. Developer Experience Issues related to Next.js logs, Error overlay, etc. Webpack Related to Webpack with Next.js.

Comments

@RobertKoval
Copy link

Link to the code that reproduces this issue

https://github.com/RobertKoval/issue_nextjs

To Reproduce

  1. Create a new project using npx create-next-app@latest
  2. run npx next build

Current vs. Expected behavior

I expected the project to compile, but instead, I encountered an error:

(node:9416) ExperimentalWarning: CommonJS module /opt/homebrew/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
   ▲ Next.js 15.0.3

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

./app/page.tsx + 1 modules
Unexpected end of JSON input


> Build failed because of webpack errors

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 23.2.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 9.4.0
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  eslint-config-next: 15.0.3
  react: 19.0.0-rc-66855b96-20241106
  react-dom: 19.0.0-rc-66855b96-20241106
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app, Developer Experience, Webpack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

@RobertKoval RobertKoval added the bug Issue was opened via the bug report template. label Nov 16, 2024
@github-actions github-actions bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Developer Experience Issues related to Next.js logs, Error overlay, etc. Webpack Related to Webpack with Next.js. labels Nov 16, 2024
@RobertKoval
Copy link
Author

I tried with different NodeJS versions, v21.7.3 and v22.11.0 works fine.

@JulioBarros
Copy link

I have this same issue with a brand new project with no edits just npx create-next-app@latest buildtest and then npm run build fails with

❯ npm run build

> [email protected] build
> next build

   ▲ Next.js 15.0.3

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

./src/app/page.tsx + 1 modules
Unexpected end of JSON input

> Build failed because of webpack errors

I'm on node version v23.2.0

@jmgibson1976
Copy link

> next build

   ▲ Next.js 15.0.3

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

./app/page.tsx + 1 modules
Unexpected end of JSON input


> Build failed because of webpack errors

Also on node version v23.2.0

@jmgibson1976
Copy link

jmgibson1976 commented Nov 17, 2024

@RobertKoval @JulioBarros

Remove the → from the text in the last link (Go to nextjs.org → becomes Go to nextjs.org) and it seems to compile fine.

Possibly improper escaping of unicode character.

I created a const:
const goto = "Go to nextjs.org \u2192";

and then replaced the line: Go to nextjs.org →

with: {goto}

and it built as well.

Take what I say with a grain of salt, im very new to typescript, react, and nextjs.

It only happens on build so perhaps there is a problem with a minimizer or other tool that webpack is configured to use?!

@JulioBarros
Copy link

That is true. It does work if you remove the "→" from the default page. So that is a good hint

I'm not using the that char or any other that might need encoding on my page though. I am using zod and react-hook-form and the only JSON on it is a valid zod spec. If I remove the form and zod spec it builds and it all builds fine in dev mode.

Right now I'm getting


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

./src/app/contact/page.tsx + 4 modules
Unexpected end of JSON input

./node_modules/remark-html/lib/index.js + 80 modules
Unexpected end of JSON input

./node_modules/remark/index.js + 110 modules
Unexpected end of JSON input

./node_modules/unist-util-visit-parents/lib/index.js + 1 modules
Unexpected end of JSON input

@agoe
Copy link

agoe commented Nov 17, 2024

maybe this helps i have nextjs 14 latest and the same problems with the build.
Found this:

23.2 breaks a few packages that use json trough webpack (date-fns) #55826
nodejs/node#55826

downgraded my node installation from 23.2 to 20.18 et voila

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. Developer Experience Issues related to Next.js logs, Error overlay, etc. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

4 participants