Config with Cache Enabled
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm' # This is all you need
- run: npm ci
- run: npm run build
npm install vs npm ci
| npm install | npm ci | |
|---|---|---|
| Speed | Normal | Faster |
| package-lock.json | May update it | Never updates it |
| Use case | Development | CI/CD |
Common Pitfalls
- Adding
cache: 'npm'is all it takes — no extra configuration needed - Cache is invalidated when
package-lock.jsonchanges
For the overall workflow structure, see GitHub Actions: Basic Auto-Deploy Setup.
Related Posts
- GitHub Actions: Basic Auto-Deploy Setup
- Managing Secrets in GitHub Actions
- Fix npm Cache Problems
- npm vs yarn: Differences and When to Use Each
Recommended Services
- Fiverr - Find freelance developers and tech experts