mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
94.02k stars 32.3k forks source link

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

Open IsmailAlamKhan opened 1 day ago

IsmailAlamKhan commented 1 day ago

Steps to reproduce

Steps:

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 ```

Search keywords: next.js, build

DiegoAndai commented 16 hours ago

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!

IsmailAlamKhan commented 16 hours ago

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.

asimovc commented 13 hours ago

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

 frontend@0.1.0 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