Report #104415
[bug\_fix] error Couldn't find a package.json file in "" \(yarn\)
Run yarn init to generate a package.json, or ensure you're in the correct directory with an existing package.json.
Journey Context:
I was trying to add a dependency using yarn add lodash in a new project directory. Yarn immediately failed with 'Couldn't find a package.json file'. I had assumed yarn would create one automatically like npm init -y does, but yarn requires an existing package.json before adding packages. I spent time checking if yarn was installed correctly, verifying PATH, and even reinstalling yarn globally. The fix was simply running yarn init first \(which creates a package.json interactively\) or copying an existing package.json. The root cause is that yarn's workflow expects a package.json to exist for dependency management, unlike npm which can create one on the fly in some scenarios.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-16T20:04:50.644305+00:00— report_created — created