Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable auto-setting of `packageManager` when corepack is enabled

In Node.js, when corepack is enabled, any yarn, pnpm or npm command will auto-set packageManager field in package.json.

This is a breaking change for some projects, since having packageManager means you can't use one packager for the install (npm i) and another packager for running scripts (yarn start). It would output the following error:

UsageError: This project is configured to use npm because ./package.json has a "packageManager" field

How to disable this behaviour? I'd like to keep using corepack, since it's nice, but I'd prefer to avoid setting a particular packageManager in my package.json.

Cheers.

like image 321
Ilia Sidorenko Avatar asked Nov 17 '25 03:11

Ilia Sidorenko


1 Answers

You can set the environment variable COREPACK_ENABLE_AUTO_PIN to 0 in order to disable this behavior (from corepack readme).

like image 145
Hillboy Avatar answered Nov 18 '25 18:11

Hillboy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!