yarn install - An unexpected error occurred: "/Users/[username]/package.json: Unexpected end of JSON input"
Using Mac - OS Catalina - Version 10.15.7
I have installed yarn using brew.
Cloned my project to the local folder and ran yarn install in my local directory where package.json resides.
error An unexpected error occurred: "/Users/[myusername]/package.json: Unexpected end of JSON input". info If you think this is a bug, please open a bug report with the information provided in "/Users/[Myusername]/[My local folder where project cloned]/yarn-error.log".
I don't understand why yarn is looking at my root directory to find package.json. Here is the partial output of error.log file to investigate the issue.
Arguments: /usr/local/Cellar/node/14.13.1/bin/node /Users/[username]/.yarn/bin/yarn.js install
PATH: /Users/[username]/.yarn/bin:/Users/[username]/.config/yarn/global/node_modules/.bin:/Users/[username]/.sdkman/candidates/java/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands
Yarn version: 1.22.5
Node version: 14.13.1
Platform: darwin x64
Trace:
SyntaxError: /Users/[username]/package.json: Unexpected end of JSON input
at JSON.parse (
npm manifest: { "name": "projectname", "version": "0.1.0", "description": "Project name App", "private": true, "license": "MIT", "author": "", "keywords": [ "gatsby" ],
--- all of my dependencies }
yarn manifest: No manifest
Lockfile: No lockfile
Don't forget that if you get this error on mac or windows it can be because you have an empty package.json in your home directory /Users/[username]/package.json.
If you have the empty file there just delete it and you are on track again.
I don't understand why yarn is looking at my root directory to find package.json.
It's to figure out if you're in a workspace or not and if your package.json is invalid it will throw
Thanks this helped a lot @medesko !!
Don't forget that if you get this error on mac or windows it can be because you have an empty package.json in your home directory /Users/[username]/package.json.
If you have the empty file there just delete it and you are on track again.
Not a problem in my case :( I don't have any package.json in home directory.
My OS is Windows 10.
The only files in my /Users/[username]/ are these:
