ref: core.nodejs
pack_ref: core
name: Node.js
description: Node.js runtime for JavaScript-based actions and sensors

distributions:
  verification:
    commands:
      - binary: node
        args:
          - "--version"
        exit_code: 0
        pattern: "v\\d+\\.\\d+\\.\\d+"
        priority: 1
  min_version: "16.0.0"
  recommended_version: "20.0.0"

installation:
  package_managers:
    - npm
    - yarn
    - pnpm
  module_support: true

execution_config:
  interpreter:
    binary: node
    args: []
    file_extension: ".js"
  environment:
    env_type: node_modules
    dir_name: node_modules
    create_command:
      - sh
      - "-c"
      - "mkdir -p {env_dir} && cp {manifest_path} {env_dir}/ 2>/dev/null || true"
    interpreter_path: null
  dependencies:
    manifest_file: package.json
    install_command:
      - npm
      - install
      - "--prefix"
      - "{env_dir}"
  env_vars:
    NODE_PATH: "{env_dir}/node_modules"

# Version-specific execution configurations.
# Each entry describes how to invoke a particular Node.js version.
# The worker uses these when an action declares a runtime_version constraint
# (e.g., runtime_version: ">=20"). The highest available version satisfying
# the constraint is selected, and its execution_config replaces the parent's.
versions:
  - version: "18"
    distributions:
      verification:
        commands:
          - binary: node18
            args:
              - "--version"
            exit_code: 0
            pattern: "v18\\."
            priority: 1
          - binary: node
            args:
              - "--version"
            exit_code: 0
            pattern: "v18\\."
            priority: 2
    execution_config:
      interpreter:
        binary: node18
        args: []
        file_extension: ".js"
      environment:
        env_type: node_modules
        dir_name: node_modules
        create_command:
          - sh
          - "-c"
          - "mkdir -p {env_dir} && cp {manifest_path} {env_dir}/ 2>/dev/null || true"
        interpreter_path: null
      dependencies:
        manifest_file: package.json
        install_command:
          - npm
          - install
          - "--prefix"
          - "{env_dir}"
      env_vars:
        NODE_PATH: "{env_dir}/node_modules"
    meta:
      lts_codename: "hydrogen"
      eol: "2025-04-30"

  - version: "20"
    is_default: true
    distributions:
      verification:
        commands:
          - binary: node20
            args:
              - "--version"
            exit_code: 0
            pattern: "v20\\."
            priority: 1
          - binary: node
            args:
              - "--version"
            exit_code: 0
            pattern: "v20\\."
            priority: 2
    execution_config:
      interpreter:
        binary: node20
        args: []
        file_extension: ".js"
      environment:
        env_type: node_modules
        dir_name: node_modules
        create_command:
          - sh
          - "-c"
          - "mkdir -p {env_dir} && cp {manifest_path} {env_dir}/ 2>/dev/null || true"
        interpreter_path: null
      dependencies:
        manifest_file: package.json
        install_command:
          - npm
          - install
          - "--prefix"
          - "{env_dir}"
      env_vars:
        NODE_PATH: "{env_dir}/node_modules"
    meta:
      lts_codename: "iron"
      eol: "2026-04-30"

  - version: "22"
    distributions:
      verification:
        commands:
          - binary: node22
            args:
              - "--version"
            exit_code: 0
            pattern: "v22\\."
            priority: 1
          - binary: node
            args:
              - "--version"
            exit_code: 0
            pattern: "v22\\."
            priority: 2
    execution_config:
      interpreter:
        binary: node22
        args: []
        file_extension: ".js"
      environment:
        env_type: node_modules
        dir_name: node_modules
        create_command:
          - sh
          - "-c"
          - "mkdir -p {env_dir} && cp {manifest_path} {env_dir}/ 2>/dev/null || true"
        interpreter_path: null
      dependencies:
        manifest_file: package.json
        install_command:
          - npm
          - install
          - "--prefix"
          - "{env_dir}"
      env_vars:
        NODE_PATH: "{env_dir}/node_modules"
    meta:
      lts_codename: "jod"
      eol: "2027-04-30"
