Contribution
Describe the user story
Corepack introduced a feature called "auto-pinning" in 0.26.0, which writes the package manager version to a packageManager field in package.json:
Two things will reduce the usage of this auto-pinning feature:
Currently, pnpm auto-pins (without a hash) in packageManager in package.json on pnpm init.
For existing projects, I don't see functionality to add a packageManager field to package.json using only pnpm.
Is there any appetite for a feature to auto-pin packageManager (only if it doesn't exist) on usage of mutative commands such as:
pnpm add
pnpm remove
- others?
(if controversial, disabled by default)
Describe the solution you'd like
package.json
pnpm add sharp with the package.json above will yield:
{
"dependencies": {
"sharp": "^0.34.3"
},
"packageManager": "pnpm@10.13.1"
}
Alternatives considered
A separate, focused command like pnpm pin or something, that would only write packageManager to package.json
Describe the drawbacks of your solution
Community objection to auto-pinning, such as this issue:
Describe alternatives you've considered
Manually setting packageManager in package.json using npm pkg set packageManager="pnpm@$(pnpm -v)"
Contribution
Describe the user story
Corepack introduced a feature called "auto-pinning" in
0.26.0, which writes the package manager version to apackageManagerfield inpackage.json:Two things will reduce the usage of this auto-pinning feature:
0.33.0Currently, pnpm auto-pins (without a hash) in
packageManagerinpackage.jsononpnpm init.For existing projects, I don't see functionality to add a
packageManagerfield topackage.jsonusing only pnpm.Is there any appetite for a feature to auto-pin
packageManager(only if it doesn't exist) on usage of mutative commands such as:pnpm addpnpm remove(if controversial, disabled by default)
Describe the solution you'd like
package.json{ "dependencies": {} }pnpm add sharpwith thepackage.jsonabove will yield:{ "dependencies": { "sharp": "^0.34.3" }, "packageManager": "pnpm@10.13.1" }Alternatives considered
A separate, focused command like
pnpm pinor something, that would only writepackageManagertopackage.jsonDescribe the drawbacks of your solution
Community objection to auto-pinning, such as this issue:
COREPACK_ENABLE_AUTO_PINshould default to0nodejs/corepack#485Describe alternatives you've considered
Manually setting
packageManagerinpackage.jsonusingnpm pkg set packageManager="pnpm@$(pnpm -v)"