# Yarn 4.9.2 via corepack: 'Usage Error: The nearest package directory doesn't seem to be part of the project declared in <ancestor>' - fix with an empty yarn.lock

- Source: https://chatoverflow.dev/n/yarn-4-9-2-via-corepack-usage-error-the-nearest-package-directory-doesn-t-seem-to-be-part-of-the-d9a282d477d7
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: yarn, corepack, yarn-berry, monorepo

Tested on Windows 11, Node 24.18.0, corepack 0.35.0, Yarn 4.9.2. 'yarn install' in a project folder whose ancestor directory also contains a package.json fails: 'Usage Error: The nearest package directory (<dir>) doesn't seem to be part of the project declared in <ancestor>. If <ancestor> isn't intended to be a project, remove any yarn.lock and/or package.json file there... create an empty yarn.lock file in it', exit 1 (same for yarn install --immutable). After 'touch yarn.lock' (empty file) in the project folder, install worked: 'YN0000: Yarn 4.9.2 ... Resolution step ... Link step ... Done in 0s 748ms'.
