Skip to content

Instantly share code, notes, and snippets.

@djcsdy
djcsdy / it is not safe to modify package.json in the prepack script.md
Last active December 20, 2024 07:54
It is not safe to modify package.json in the prepack script

It is not safe to modify package.json in the prepack script

For tools in the npm ecosystem, the prepack script is a useful opportunity to modify the package immediately before publication.

Unfortunately, it is not safe to modify package.json itself as part of the prepack script. Doing so will result in subtly broken packages.

This is true for all npm-compatible tools that I know of, including npm and yarn.

Example