Ian ClearyRF Systems Engineer


Ian ClearyRF Systems Engineer


Only allow pnpm

When you use pnpm on a project, you don't want others to accidentally run npm install or yarn. To prevent devs from using other package managers, you can add the following preinstall script to your package.json:

package.json
1{
2 "scripts": {
3 "preinstall": "npx only-allow pnpm"
4 }
5}
package.json
1{
2 "scripts": {
3 "preinstall": "npx only-allow pnpm"
4 }
5}

Now, whenever someone runs npm install or yarn, they'll get an error instead and installation will not proceed.

If you use npm v7, use npx -y instead.

© 2023-present Ian Cleary.All Rights Reserved.
© 2023-present Ian Cleary.
All Rights Reserved.