nodejs_runtime
A Node.js runtime that an app runs on or ships with, provided as NodejsRuntimeInfo. It has no toolchain attribute, so a nodejs toolchain can name one as its default runtime. Its kind is native when node is a Node.js binary for the target platform (typically picked by a select); pointer when target_independent = True and node is one file that runs Node.js on every platform, such as a DotSlash file; and host when target_independent = True and there is no node: nothing is bundled, and Node.js comes from the host, for example from PATH. prelude//nodejs/runtimes:host is a ready-made host runtime. A native runtime without node, as when a select falls back to None, has no binary for the target platform. files are staged next to node, keyed by their path relative to it (relative paths with / separators, no : and no . or .. segments, as are posix_exe and windows_exe). posix_exe (default "node") and windows_exe (default "node.exe") are where the executable to run sits on POSIX and on Windows. A native runtime stages node at windows_exe on Windows and at posix_exe elsewhere. A pointer runtime stages node at posix_exe on every platform, and its windows_exe must name one of files, such as a node.bat that runs node. No two paths staged on a platform may be the same or nest, ignoring case as Windows and macOS do. A host runtime has no files. version is the Node.js version, for example "24.18.1". node_args and env are the flags and environment variables to run node with. exe, when set, runs the runtime in place, for example a wrapper that adds flags.
Function Signature
def nodejs_runtime(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str | target_name_glob] = [],
within_view: list[str | target_name_glob] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
contacts: list[str] = [],
env: dict[str, str] = {},
exe: None | str = None,
files: dict[str, str] = {},
labels: list[str] = [],
node: None | str = None,
node_args: list[str] = [],
posix_exe: str = "node",
target_independent: bool = False,
version: None | str = None,
windows_exe: str = "node.exe",
) -> None
Parameters
-
name: (required)name of the target
-
default_target_platform: (defaults to:None)specifies the default target platform, used when no platforms are specified on the command line
-
target_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
exec_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with an execution platform
-
visibility: (defaults to:[])a list of visibility patterns restricting what targets can depend on this one
-
within_view: (defaults to:["PUBLIC"])a list of visibility patterns restricting what this target can depend on
-
metadata: (defaults to:{})a key-value map of metadata associated with this target
-
tests: (defaults to:[])a list of targets that provide tests for this one
-
modifiers: (defaults to:[])an array of modifiers associated with this target
-
contacts: (defaults to:[])A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.
contacts = [ 'Joe Sixpack', 'Erika Mustermann' ] -
labels: (defaults to:[])Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query().