corepack
corepack copied to clipboard
Usage Error: This project is configured to use yarn
If you have pnpm and yarn projects try change to yarn_project and run pnpm --dir pnpm_project or change to pnpm_project and run yarn --cwd yarn_project. There is error Usage Error: This project is configured to use yarn. Should be no error to use like this.
That's the expected behaviour. See the documentation:
COREPACK_ENABLE_STRICTcan be set to0to prevent Corepack from throwing error if the package manager does not correspond to the one defined for the current project. This means that if a user is using the package manager specified in the current project, it will use the version specified by the project'spackageManagerfield. But if the user is using other package manager different from the one specified for the current project, it will use the system-wide package manager version.
You can also explicitly call corepack yarn ... on pnpm projects (or corepack pnpm ... on Yarn projects) to bypass this check.
Even with no COREPACK_ENABLE_STRICT the error should not happen if pnpm --dir or yarn --cwd point to location outside current project.
Corepack has no knowledge of what the underlying package manager CLIs look like, and can only make trivial assumptions about it. If you want a similar behaviour, you'll need to cd into the target directory and run the command from there.
can only make trivial assumptions about it
Can be trivial if --dir is on pnpm or --cwd is on yarn then skip warning.
In my case, the error occurred because I had pnpm in the script that I was trying to run with yarn.