pnpm / pnpm

Fast, disk space efficient package manager
https://pnpm.io
MIT License
29.19k stars 978 forks source link

[pjson] support Corepack's `"packageManager"` field #5583

Open DerekNonGeneric opened 1 year ago

DerekNonGeneric commented 1 year ago

Describe the user story

I have seen pnpm complain about my projects not being set up for pnpm when wanting to use it in a project that had previously been set up to be used w/ npm. I am unsure what heuristics y'all currently use, but why not perhaps also use Corepack's "packageManager" field defined in a project's package.json to more accurately make this determination? It would likely more accurately reflect the intent of the project's developer(s)/maintainer(s).

Describe the solution you'd like

Just consider it for now (is experimental).

Describe the drawbacks of your solution

Can only specify a single version (version ranges are not supported).

Describe alternatives you've considered

This issue is just to put it on your radar, so who knows what might come of it.

zkochan commented 1 year ago

If it only will print a warning or throw an error, then it is not hard to implement. Here is the place where the root package.json file is read: https://github.com/pnpm/pnpm/blob/e19356c32fb87e1555d842cd0fdec7382ce74a91/packages/config/src/index.ts#L527-L530