admin管理员组文章数量:1433902
I'm completely at a loss. I have a React app I've been working on for some time and yesterday I found I was unable to build it. I keep getting the following error on 'npm run build': Creating an optimized production build... Failed to compile.
Unexpected end of JSON input
Steps I have taken:
- npm cache clean --force
- rm -rf node_modules package-lock.json
- rm -rf ~/.npm
- npm install
- checked all .json formatting
- tested the package.json file with node -e
- Used yarn to build (same error)
I have created a new React project and was able to build without errors. I have taken all the packages from package.json in my problem project, pasted them into a new project and was able to build without error.
I'm not sure what to do now other than completely rebuild my project piece by piece.
I'm completely at a loss. I have a React app I've been working on for some time and yesterday I found I was unable to build it. I keep getting the following error on 'npm run build': Creating an optimized production build... Failed to compile.
Unexpected end of JSON input
Steps I have taken:
- npm cache clean --force
- rm -rf node_modules package-lock.json
- rm -rf ~/.npm
- npm install
- checked all .json formatting
- tested the package.json file with node -e
- Used yarn to build (same error)
I have created a new React project and was able to build without errors. I have taken all the packages from package.json in my problem project, pasted them into a new project and was able to build without error.
I'm not sure what to do now other than completely rebuild my project piece by piece.
Share Improve this question asked Nov 18, 2024 at 22:13 C PaynterC Paynter 911 silver badge7 bronze badges 1- I am not sure specifically what the problem is but I can tell you the approach I use to find the problem in these kind of situations. If you used git you can make a separate branch and start reverting commit by commit and seeing which commit changed the build from working to non working, it might seem like this will take a while but it will give you a deeper understanding in the end of the framework you are using. Good luck! – Lars Vonk Commented Nov 18, 2024 at 23:06
3 Answers
Reset to default 17I'm having the same issue for my react application since today and i think its a bug in the new NodeJs version. I fixed it by downgrading my version from 23.2.0 (newest at this time) to the LTS 22.11.0. Hope this will do the trick for you aswell.
As @Max mentioned it's a bug in latest nodejs.
We just changed the first line of the pipeline configuration (bitbucket-pipelines.yml
) from image: node
to image: node:lts
and the problem was solved.
I setup my Docker file with node version:22-alpine3.19.
Downgrading the NodeJS version works.
本文标签: reactjsReact Build ErrorUnexpected end of JSON inputStack Overflow
版权声明:本文标题:reactjs - React Build Error - Unexpected end of JSON input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745591037a2665198.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论