unexpected end of json input error when I try to create a react app
Asked Answered
C

1

8

I keep getting the error of unexpected end of json input when I run the command npx create-react app. Here is the error message:

error An unexpected error occurred: "C:\\Users\\Josh\\AppData\\Local\\Yarn\\Cache\\v6\\npm-@svgr-babel-plugin-add-jsx-attribute-5.4.0-81ef61947bb268eb9d50523446f9c638fb355906-integrity\\node_modules\\@svgr\\babel-plugin-add-jsx-attribute\\.yarn-metadata.json: Unexpected end of JSON input".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\Josh\\Documents\\edconnect-react\\tic-tac-toe\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
info There appears to be trouble with your network connection. Retrying...
Coincidence answered 17/7, 2021 at 17:26 Comment(0)
M
3

As noted above yarn cache clean should deal with most issues. However, today I came across this situation and none of these worked for me:

yarn cache clean
yarn cache clean --force
yarn cache clean --mirror
yarn cache clean --all

The issue was that by running npx, or perhaps an npm/yarn command earlier there was a package.json file that was created in my home directory with nothing in it

by removing this file via

rm ~/package.json

yarn (and npx commands that invoke yarn) were able to run successfully in my project

Microelement answered 21/2, 2023 at 12:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.