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 testUpdates documentation and fixes various typos and mirror option issues
- –Documentation update related to absence of Lockfile
- –Correct mirror option typos
- –Readme update on checkout version v6
- –Advanced document update on checkout version v6
Removes always-auth configuration handling and upgrades dependencies
- –Remove always-auth configuration handling
- –Upgrade @actions/cache from 4.0.3 to 4.1.0
- –Upgrade actions/checkout from 5 to 6
- –Upgrade js-yaml from 3.14.1 to 3.14.2
- –Add example for restore-only cache in documentation
Limits automatic caching to npm only and includes breaking changes documentation
- –Limit automatic caching to npm, update workflows and documentation
- –Upgrade ts-jest from 29.1.2 to 29.4.1 and document breaking changes in v5
- –Upgrade prettier from 2.8.8 to 3.6.2
- –Upgrade actions/publish-action from 0.3.0 to 0.4.0
Top in Cloud & DevOps
Related Repositories
Discover similar tools and frameworks used by developers
Portainer
Web-based management platform for multi-orchestrator container environments.
Temporal
Distributed system for durable workflow execution with automatic failure handling, retries, and state persistence.
Blackbox Exporter
Prometheus exporter for blackbox probing of network endpoints over HTTP, TCP, DNS, ICMP, and gRPC protocols.
OpenLens
Community-built Kubernetes IDE without authentication requirements.
Watchtower
Automated Docker container updates via registry polling.