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

customTypes

Extend syncpack to manage other parts of package.json files than those provided by default.

Custom types behave indentically to the default dependency types (such as prod or peer). When you define a custom type, you are adding to the list of valid names that can be passed to the:

This is how the default dependency types are defined:

.syncpackrc.json
{
"$schema": "./node_modules/syncpack/schema.json",
"customTypes": {
"dev": {
"strategy": "versionsByName",
"path": "devDependencies"
},
"local": {
"strategy": "name~version",
"namePath": "name",
"path": "version"
},
"overrides": {
"strategy": "versionsByName",
"path": "overrides"
},
"peer": {
"strategy": "versionsByName",
"path": "peerDependencies"
},
"pnpmOverrides": {
"strategy": "versionsByName",
"path": "overrides",
"source": "PnpmWorkspace"
},
"prod": {
"strategy": "versionsByName",
"path": "dependencies"
},
"resolutions": {
"strategy": "versionsByName",
"path": "resolutions"
}
}
}

Pick a strategy below based on the shape of your data.

name@version

A single string combining name and version, separated by @.

package.json
{
"packageManager": "pnpm@7.27.0"
}
.syncpackrc.json
{
"customTypes": {
"packageManager": {
"strategy": "name@version",
"path": "packageManager"
}
}
}

[name] Required

The name of the new dependency type you are adding to syncpack. Syncpack ships with built-in types like prod, dev, and peer; defining a custom type adds your chosen name to that list, ready to be referenced from:

  1. --dependency-types
  2. versionGroup.dependencyTypes
  3. semverGroup.dependencyTypes
  4. dependencyGroup.dependencyTypes

[name].path Required

The location in each package.json of the "name@version" string. Use dot notation for nested properties (eg. packageManager, some.nested.property).

[name].strategy Required

Must be "name@version".

name~version

The name and version live at two separate paths. Both must point directly to string values, not to a containing object.

package.json
{
"devEngines": {
"runtime": {
"name": "node",
"version": "22.11.0"
}
}
}
.syncpackrc.json
{
"customTypes": {
"devEnginesRuntime": {
"strategy": "name~version",
"namePath": "devEngines.runtime.name",
"path": "devEngines.runtime.version"
}
}
}

A common mistake is pointing path at the containing object (devEngines.runtime) and namePath at name relative to it. Both paths are absolute from the package.json root and must resolve to strings.

[name] Required

The name of the new dependency type you are adding to syncpack. Syncpack ships with built-in types like prod, dev, and peer; defining a custom type adds your chosen name to that list, ready to be referenced from:

  1. --dependency-types
  2. versionGroup.dependencyTypes
  3. semverGroup.dependencyTypes
  4. dependencyGroup.dependencyTypes

[name].path Required

The location in each package.json of the version string. Absolute from the package.json root; must point to a string.

[name].namePath Required

The location in each package.json of the dependency name. Absolute from the package.json root; must point to a string.

[name].strategy Required

Must be "name~version".

version

A bare version string with no name in the data. The custom type's key is used as the dependency name.

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

Here the dependency is reported as node because that is the custom type's key.

[name] Required

The name of the new dependency type you are adding to syncpack. Syncpack ships with built-in types like prod, dev, and peer; defining a custom type adds your chosen name to that list, ready to be referenced from:

  1. --dependency-types
  2. versionGroup.dependencyTypes
  3. semverGroup.dependencyTypes
  4. dependencyGroup.dependencyTypes

For the version strategy specifically, this name is also used as the dependency name in reports and grouping (since the data has no name field of its own).

[name].path Required

The location in each package.json of the version string. Use dot notation for nested properties (eg. engines.node).

[name].strategy Required

Must be "version".

versionsByName

A typical dependency object where keys are package names and values are version strings.

package.json
{
"dependencies": {
"pnpm": "10.10.0",
"prettier": "3.5.3"
}
}
.syncpackrc.json
{
"customTypes": {
"prod": {
"strategy": "versionsByName",
"path": "dependencies"
}
}
}

[name] Required

The name of the new dependency type you are adding to syncpack. Syncpack ships with built-in types like prod, dev, and peer; defining a custom type adds your chosen name to that list, ready to be referenced from:

  1. --dependency-types
  2. versionGroup.dependencyTypes
  3. semverGroup.dependencyTypes
  4. dependencyGroup.dependencyTypes

[name].path Required

The location in each package.json of the { "name": "version" } object. Use dot notation for nested properties (eg. dependencies, pnpm.overrides).

[name].strategy Required

Must be "versionsByName".