nodejs
The Node.js Javascript runtime (including Corepack).
Backend: pants.backend.experimental.openapi.lint.spectral
Config section: [nodejs]
Basic options
package_manager
--nodejs-package-manager=<str>
PANTS_NODEJS_PACKAGE_MANAGER
[nodejs]
package_manager = <str>
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.
package_managers
--nodejs-package-managers="{'key1': val1, 'key2': val2, ...}"
PANTS_NODEJS_PACKAGE_MANAGERS
[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
corepack_env_vars
--nodejs-corepack-env-vars="[<shell_str>, <shell_str>, ...]"
PANTS_NODEJS_COREPACK_ENV_VARS
[nodejs]
corepack_env_vars = [
<shell_str>,
<shell_str>,
...,
]
[]
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 fieldnodejs_corepack_env_vars
on local_environment
, docker_environment
, or remote_environment
targets.executable_search_paths
--nodejs-executable-search-paths="[<binary-paths>, <binary-paths>, ...]"
PANTS_NODEJS_EXECUTABLE_SEARCH_PATHS
[nodejs]
executable_search_paths = [
<binary-paths>,
<binary-paths>,
...,
]
[ "<PATH>" ]
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.
nodejs_executable_search_paths
on local_environment
, docker_environment
, or remote_environment
targets.known_versions
--nodejs-known-versions="['<str>', '<str>', ...]"
PANTS_NODEJS_KNOWN_VERSIONS
[nodejs]
known_versions = [
'<str>',
'<str>',
...,
]
[ "v16.15.0|macos_arm64|ad8d8fc5330ef47788f509c2af398c8060bb59acbe914070d0df684cd2d8d39b|29126014", "v16.15.0|macos_x86_64|a6bb12bbf979d32137598e49d56d61bcddf8a8596c3442b44a9b3ace58dd4de8|30561503", "v16.15.0|linux_arm64|b4080b86562c5397f32da7a0723b95b1df523cab4c757688a184e3f733a7df56|21403276", "v16.15.0|linux_x86_64|ebdf4dc9d992d19631f0931cca2fc33c6d0d382543639bc6560d31d5060a8372|22031988" ]
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.
resolves
--nodejs-resolves="{'key1': val1, 'key2': val2, ...}"
PANTS_NODEJS_RESOLVES
[nodejs.resolves]
key1 = val1
key2 = val2
...
{}
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).
search_path
--nodejs-search-path="[<binary-paths>, <binary-paths>, ...]"
PANTS_NODEJS_SEARCH_PATH
[nodejs]
search_path = [
<binary-paths>,
<binary-paths>,
...,
]
[ "<PATH>" ]
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".
nodejs_search_path
on local_environment
, docker_environment
, or remote_environment
targets.url_platform_mapping
--nodejs-url-platform-mapping="{'key1': val1, 'key2': val2, ...}"
PANTS_NODEJS_URL_PLATFORM_MAPPING
[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.
url_template
--nodejs-url-template=<str>
PANTS_NODEJS_URL_TEMPLATE
[nodejs]
url_template = <str>
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.
version
--nodejs-version=<str>
PANTS_NODEJS_VERSION
[nodejs]
version = <str>
v16.15.0
Use this version of nodejs.
Deprecated options
None
Related subsystems
None