Catalog / Cloudflare Developer Platform

Workers - Pin your npm version in Workers Builds with packageManager

yesterdayOriginal notes

You can now choose the npm version that Workers Builds uses by setting the packageManager field in your package.json. Before the build installs dependencies, it installs the npm version you set, so a lockfile written by a newer npm version installs the same way in your build as it does locally.

package.jsonjson
{
	"packageManager": "npm@11.19.1"
}

The packageManager field also sets the version of Yarn, pnpm, and Bun. Use an exact version, such as npm@11.19.1, not a range. Workers Builds does not use the engines.npm field to choose an npm version.

For more information, refer to Package manager versions.