Skip to content
This documentation is for v14 and up, the docs for v13 are archived.

Synchronise Node.js version in monorepo

Synchronise Node.js version in monorepo

Ensure engines.node version is identical in every package.

1. Add a custom type

I've chosen a name of nodeEngine but it can be anything you like. Once defined, every syncpack command checks engines.node alongside the default dependency types.

.syncpackrc.json
{
"customTypes": {
"nodeEngine": {
"path": "engines.node",
"strategy": "version"
}
}
}

2. Look for mismatches

Perform a one-off check for every usage of engines.node in your monorepo.

syncpack list --dependency-types nodeEngine

If the versions are not identical, they can be synchronised to all use the highest of the semver versions currently in use.

syncpack fix --dependency-types nodeEngine

3. Relax the rules (optional)

If you don't want the Node.js version to be identical in every package but do want them all to be compatible with each other, you can use a Same Range Version Group.

.syncpackrc.json
{
"customTypes": {
"nodeEngine": {
"path": "engines.node",
"strategy": "version"
}
},
"versionGroups": [
{
"dependencyTypes": ["nodeEngine"],
"policy": "sameRange"
}
]
}