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

Getting "Unexpected end of JSON input" when building a next.js app #44485

Open
IsmailAlamKhan opened this issue Nov 20, 2024 · 5 comments
Open
Assignees
Labels
status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@IsmailAlamKhan
Copy link

IsmailAlamKhan commented Nov 20, 2024

Steps to reproduce

Steps:
1.
2.
3.

Current behavior

No response

Expected behavior

No response

Context

I have been using Material UI on my next.js project since a long time and haven't face this issue but suddenly today when I was trying to build the project I keep getting the following error

./node_modules/@mui/lab/LoadingButton/LoadingButton.js + 3 modules
Unexpected end of JSON input

./node_modules/@mui/material/Autocomplete/Autocomplete.js + 6 modules
Unexpected end of JSON input

./node_modules/@mui/material/Backdrop/Backdrop.js + 1 modules
Unexpected end of JSON input

./node_modules/@mui/material/Button/Button.js + 3 modules
Unexpected end of JSON input

./node_modules/@mui/material/ButtonBase/ButtonBase.js + 6 modules
Unexpected end of JSON input

I have searched a lot on this but no solution fixed this issue, if required I can provide the package.json as well.

Your environment

npx @mui/envinfo
  System:
    OS: macOS 15.1
  Binaries:
    Node: 23.2.0 - /opt/homebrew/bin/node
    npm: 10.9.0 - /opt/homebrew/bin/npm
    pnpm: 9.7.1 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.71
    Edge: Not Found
    Safari: 18.1
  npmPackages:
    @emotion/react: ^11.11.1 => 11.13.5 
    @emotion/styled: ^11.11.0 => 11.13.5 
    @mui/base:  5.0.0-beta.40 
    @mui/core-downloads-tracker:  6.1.8 
    @mui/icons-material: ^6.1.8 => 6.1.8 
    @mui/lab: ^5.0.0-alpha.173 => 5.0.0-alpha.173 
    @mui/material: ^6.1.8 => 6.1.8 
    @mui/private-theming:  6.1.8 
    @mui/styled-engine:  6.1.8 
    @mui/system:  6.1.8 
    @mui/types:  7.2.19 
    @mui/utils:  5.16.6 
    @mui/x-data-grid: ^7.22.2 => 7.22.2 
    @mui/x-date-pickers: ^7.22.2 => 7.22.2 
    @mui/x-internals:  7.21.0 
    @types/react: ^18.0.0 => 18.3.12 
    react: ^18 => 18.3.1 
    react-dom: ^18 => 18.3.1 
    styled-components: ^6.1.1 => 6.1.13 
    typescript: ^5.5.4 => 5.6.3 ```
</details>


**Search keywords**: next.js, build
@IsmailAlamKhan IsmailAlamKhan added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 20, 2024
@DiegoAndai DiegoAndai self-assigned this Nov 21, 2024
@DiegoAndai
Copy link
Member

Hey @IsmailAlamKhan, thanks for the report and for using Material UI 😊.

Could you provide a reproduction? This would help debug the issue a lot. For example, if you could share a repository with your project, that would work. Even better if it's a minimal reproduction. Thank you!

@DiegoAndai DiegoAndai added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 21, 2024
@IsmailAlamKhan
Copy link
Author

Hey thanks a lot for responding I really appreciate it.

I wasn't able to reproduce this on another project but one thing is I was on Node.JS 23 so I asked my colleague to try it. He had Node.JS 22 and the same project built without any issues. So I tried the same on Node.JS 22 and it works now. So maybe it's an issue with Node.JS 23? Also one thing the same project built on my Windows PC without any issues.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 21, 2024
@asimovc
Copy link

asimovc commented Nov 21, 2024

I having the same problem and get this error when compiling with npm run build

 [email protected] build
> next build

  ▲ Next.js 14.2.11
  - Environments: .env

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

./node_modules/@mui/material/Avatar/Avatar.js + 2 modules
Unexpected end of JSON input

./node_modules/@mui/material/Box/Box.js + 2 modules
Unexpected end of JSON input

./node_modules/@mui/material/Button/Button.js + 3 modules
Unexpected end of JSON input

./node_modules/@mui/material/ButtonBase/ButtonBase.js + 9 modules
Unexpected end of JSON input

./node_modules/@mui/material/DefaultPropsProvider/DefaultPropsProvider.js + 1 modules
Unexpected end of JSON input


> Build failed because of webpack errors

@FrankChen021
Copy link

Same problem suffered when running npm run build under v23.2.0 on macOS

node --version
v23.2.0
  ▲ Next.js 14.2.8
  - Environments: .env.local

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

./node_modules/@mui/material/ButtonBase/ButtonBase.js + 5 modules
Unexpected end of JSON input

./node_modules/@mui/material/IconButton/IconButton.js + 1 modules
Unexpected end of JSON input

./node_modules/@mui/material/LinearProgress/LinearProgress.js + 1 modules
Unexpected end of JSON input

./node_modules/@mui/material/Popper/Popper.js + 56 modules
Unexpected end of JSON input

./node_modules/@mui/material/Tooltip/Tooltip.js + 2 modules
Unexpected end of JSON input


> Build failed because of webpack errors

dependencies of mui in the package.json are:

    "@mui/icons-material": "^6.1.0",
    "@mui/material": "^6.1.0",
    "@mui/x-date-pickers": "^7.17.0",

@FrankChen021
Copy link

After switching the node from v23 to v22.11.0(LTS) and cleaning up the .next folder and then re-build, the problem was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants