Skip to content

Commit 4db6426

Browse files
added more options for only-allow
1 parent 873885b commit 4db6426

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docs/only-allow-pnpm.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: only-allow-pnpm
33
title: Only Allow PNPM
44
---
55

6-
When many developers are working on the same project together, you need a failsafe in case someone accidentally runs commands with another package manager (like NPM, Yarn, Bun).
6+
When many developers are working on the same project together, you need a failsafe in case someone accidentally runs commands with another package manager (like NPM, Yarn, or Bun).
77

88
To prevent dependency management conflicts between package managers:
99

@@ -25,6 +25,7 @@ engine-strict=true
2525
},
2626
"packageManager": {
2727
"name": "pnpm",
28+
"version": "10.13.1",
2829
"onFail": "error"
2930
}
3031
},
@@ -35,7 +36,7 @@ engine-strict=true
3536
}
3637
```
3738

38-
- Now, when you run `npm i`, `npm i -D` (or an equivalent), these commands return this error (before the preinstall script can run):
39+
- Now, when you run `npm i`, `npm i -D` (or an equivalent), these commands return this error:
3940

4041
```
4142
username@hostname some-project % npm i -D package
@@ -49,3 +50,16 @@ npm error EBADDEVENGINES required: { name: 'pnpm', onFail: 'error' }
4950
npm error EBADDEVENGINES }
5051
npm error A complete log of this run can be found in: /Users/username/.npm/_logs/2021-08-21T00_00_00_000Z-debug-0.log
5152
```
53+
54+
Alternatively, in your `package.json`, you can specify the following `preinstall` script:
55+
56+
```
57+
{
58+
"scripts": {
59+
"preinstall": "npx only-allow pnpm"
60+
}
61+
}
62+
```
63+
64+
- You may also install the package `only-allow` as a dev dependency.
65+
- For NPM version 7+, you may need to run `npx -y only-allow pnpm` instead.

0 commit comments

Comments
 (0)