The Node.js Javascript runtime (including Corepack).

Backend: pants.backend.experimental.openapi.lint.spectral
Config section: [nodejs]

Basic options




default: npm

Default Node.js package manager to use.

You can either rely on this default together with the [nodejs].package_managers option, or specify the package.json#packageManager tool and version in the package.json of your project.

Specifying conflicting package manager versions within a multi-package workspace is an error.


--nodejs-package-managers="{'key1': val1, 'key2': val2, ...}"


  "npm": "8.5.5"

A mapping of package manager versions to semver releases.

Many organizations only need a single version of a package manager, which is a good default and often the simplest thing to do.

The version download is managed by Corepack. This mapping corresponds to the https://github.com/nodejs/corepack#known-good-releases setting, using the --activate flag.

Advanced options




default: v16.15.0

Use this version of nodejs.


--nodejs-known-versions="['<str>', '<str>', ...]"



Known versions to verify downloads against.

Each element is a pipe-separated string of version|platform|sha256|length, where:

- `version` is the version string
- `platform` is one of [linux_arm64,linux_x86_64,macos_arm64,macos_x86_64],
- `sha256` is the 64-character hex representation of the expected sha256
digest of the download file, as emitted by `shasum -a 256`
- `length` is the expected length of the download file in bytes, as emitted by
`wc -c`

E.g., 3.1.2|macos_x86_64|6d0f18cd84b918c7b3edd0203e75569e0c7caecb1367bbbe409b44e28514f5be|42813.

Values are space-stripped, so pipes can be indented for readability if necessary.




default: https://nodejs.org/dist/{version}/node-{version}-{platform}.tar

URL to download the tool, either as a single binary file or a compressed file (e.g. zip file). You can change this to point to your own hosted file, e.g. to work with proxies or for access via the filesystem through a file:$abspath URL (e.g. file:/this/is/absolute, possibly by templating the buildroot in a config file).

Use {version} to have the value from --version substituted, and {platform} to have a value from --url-platform-mapping substituted in, depending on the current platform. For example, https://github.com/.../protoc-{version}-{platform}.zip.


--nodejs-url-platform-mapping="{'key1': val1, 'key2': val2, ...}"


  "linux_arm64": "linux-arm64",
  "linux_x86_64": "linux-x64",
  "macos_arm64": "darwin-arm64",
  "macos_x86_64": "darwin-x64"

A dictionary mapping platforms to strings to be used when generating the URL to download the tool.

In --url-template, anytime the {platform} string is used, Pants will determine the current platform, and substitute {platform} with the respective value from your dictionary.

For example, if you define {"macos_x86_64": "apple-darwin", "linux_x86_64": "unknown-linux"}, and run Pants on Linux with an intel architecture, then {platform} will be substituted in the --url-template option with unknown-linux.


--nodejs-resolves="{'key1': val1, 'key2': val2, ...}"


default: {}

A mapping of names to lockfile paths used in your project.

Specifying a resolve name is optional. If unspecified, the default resolve name is calculated by taking the path from the source root to the directory containing the lockfile and replacing '/' with '.' in that path.

Example: An npm lockfile located at src/js/package/package-lock.json' will result in a resolve named js.package`, assuming src/ is a source root.

Run pants generate-lockfiles to generate the lockfile(s).


--nodejs-executable-search-paths="[<binary-paths>, <binary-paths>, ...]"



The PATH value that will be used to find any tools required to run nodejs processes. The special string "<PATH>" will expand to the contents of the PATH env var.

Can be overriden by field nodejs_executable_search_paths on local_environment, docker_environment, or remote_environment targets.


--nodejs-search-path="[<binary-paths>, <binary-paths>, ...]"



A list of paths to search for Node.js distributions.

This option is only used if a templated url download specified via [nodejs].known_versions does not contain a version matching the configured [nodejs].version range.

You can specify absolute paths to binaries and/or to directories containing binaries. The order of entries does not matter.

The following special strings are supported:

For all runtime environment types:

  • <PATH>, the contents of the PATH env var

When the environment is a local_environment target:

  • <ASDF>, all Node.js versions currently configured by ASDF (asdf shell, ${HOME}/.tool-versions), with a fallback to all installed versions
  • <ASDF_LOCAL>, the ASDF binaries with the version in BUILD_ROOT/.tool-versions
  • <NVM>, all NodeJS versions under $NVM_DIR/versions/node
  • <NVM_LOCAL>, the nvm installation with the version in BUILD_ROOT/.nvmrc
    Note that the version in the .nvmrc file has to be on the form "vX.Y.Z".

Can be overriden by field nodejs_search_path on local_environment, docker_environment, or remote_environment targets.


--nodejs-corepack-env-vars="[<shell_str>, <shell_str>, ...]"


default: []

Environment variables to set for corepack invocations.

Entries are either strings in the form ENV_VAR=value to set an explicit value; or just ENV_VAR to copy the value from Pants's own environment.

Review https://github.com/nodejs/corepack#environment-variables for available variables.

Can be overriden by field nodejs_corepack_env_vars on local_environment, docker_environment, or remote_environment targets.

Deprecated options