PSA: How to set minimum release age for your package manager (they all do it differently)
1mon 6d ago by lemmy.zip/u/tyteen4a03 in javascript@programming.devBecause there's no guide on how each package manager sets their minimumReleaseAge and every package manager uses a different format... (can we please get a standards committee going for security-related configs like these?)
Note: unless otherwise specified, X is a number ONLY. No date units (don't specify 7d or 1440m. Your config will error.)
And for the love of your favourite deity, remove all carets (^) from your package.json unless you know what you are doing. Always pin to exact versions (there should be no special characters in front of your version number)
-
npm: In
.npmrc,min-release-age=X. X is the number of days. Requires npmv11.10.0or above. -
pnpm: In
pnpm-workspace.yaml, setminimumReleaseAge: X. X is the number of minutes. Requires pnpmv10.16.0or above. From v11 onwards, the default is1440minutes (1 day) -
Yarn: In
.yarnrc.yml, setnpmMinimalAgeGate: X. X is a duration (date units supported arems, s, m, h, d, w, e.g.7d). If no duration is specified, then it is parsed as minutes (i.e.npmMinimalAgeGate: 1440is equal tonpmMinimalAgeGate: 1440m). Requires Yarnv4.11or above (Yarnv4.10also has the option, but only supported minutes as a raw number) -
Deno: In
deno.json, set"minimumDependencyAge": "X". X can be a number in minutes, a ISO-8601 Duration or a RFC3339 absolute timestamp (basically anything that looks like a date; if you are in Freedom Country remember to swap the month and the date) Requires Denov2.6.0or above. -
Bun: In
bunfig.toml, set:[install] minimumReleaseAge = X
X is the number of seconds. Requires Bun v1.3.0 or above.
What about if there's a patch for a CVE? Do you need to disable the config, update, then re-enable it, or is it possible to bypass per-project?
In pnpm you can override this. I don't think you can in npm.
Thanks for the info.
I noticed that npm finally requires approval to run postinstall scripts: https://github.com/orgs/community/discussions/198547.Just noticed this when I was setting up a dev environment for my wife. Another good feature copied from pnpm :)