setup-node: Configure Node.js in GitHub Actions
Node.js version management and dependency caching for workflows.
Learn more about setup-node
setup-node is a GitHub Actions utility that configures Node.js runtime environments within continuous integration workflows. It downloads and installs specified Node.js versions from official distribution channels, sets up the appropriate PATH environment variables, and optionally configures package manager caching layers for npm, yarn, or pnpm. The action supports version resolution through exact version numbers, semantic version ranges, or symbolic references like LTS release channels. It implements matrix strategy compatibility to enable parallel testing across multiple Node.js versions and operating systems within a single workflow definition. The caching mechanism stores dependency directories between workflow runs using GitHub's cache service to reduce installation time in subsequent executions.
Dependency caching integration
Automatically detects and caches npm, yarn, or pnpm dependencies based on package manager configuration in package.json. Supports custom cache paths and multiple dependency file formats including package-lock.json, yarn.lock, and .tool-versions.
Version resolution flexibility
Accepts semantic versioning notation, version aliases (lts/*, latest, nightly, canary), and reads versions from multiple file formats (.nvmrc, .node-version, package.json). The check-latest option verifies available versions against the Node.js release repository.
Registry authentication configuration
Configures npm and yarn authentication at the project level through .npmrc and .yarnrc files, supporting both GPR (GitHub Package Registry) and custom npm registries via environment variables and token management.
// .github/workflows/test.yml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm testAutomatic caching now applies only to npm; yarn and pnpm require explicit cache configuration.
- –Update workflows to explicitly enable caching for yarn or pnpm if used, as automatic detection is removed.
- –Review dependency lock files to ensure npm is the package manager or add cache-dependency-path input.
Breaking: auto-caches dependencies when package.json declares packageManager; requires runner ≥v2.327.1 (Node 24).
- –Set package-manager-cache: false to disable new automatic caching if it conflicts with your workflow.
- –Upgrade your GitHub Actions runner to v2.327.1 or later before adopting this release.
Internal workflow change only; adds publishing automation for immutable action packages with no user-facing impact.
- –Release notes do not specify any breaking changes, new requirements, or migration steps for users.
- –No functional changes to setup-node behavior; update is safe to adopt without action.
Top in Cloud & DevOps
Related Repositories
Discover similar tools and frameworks used by developers
kubespray
Production-grade Kubernetes deployment via Ansible playbooks.
configure-aws-credentials
GitHub Action for AWS credential resolution in workflows.
compose
YAML-defined container lifecycle management and orchestration tool.
watchtower
Automated Docker container updates via registry polling.
dockge
Self-hosted Docker Compose manager with real-time terminal streaming.