| name | frontend-ci-fix |
| description | Guide for fixing GitHub Actions CI issues in Next.js frontend projects. Includes resolving cache errors, TypeScript type errors, test configuration issues, and E2E test failures. Invoke when user reports CI build failures or TypeScript errors. |
Frontend CI Fix Guide
This guide covers common CI/CD issues in Next.js/TypeScript frontend projects and their solutions.
Common Issues & Solutions
1. Cache Path Resolution Error
Error:
Some specified paths were not resolved, unable to cache dependencies.
Cause: cache-dependency-path in setup-node action uses relative path that doesn't resolve correctly in CI.
Solution: Remove cache configuration or use absolute path:
- uses: actions/setup-node@v4
with:
node-version: '22'
2. Package Lock Mismatch
Error:
npm error `npm ci` can only install packages when your package.json
and package-lock.json are in sync.
Solution: Run npm install locally and commit the updated lock file:
npm install
git add package-lock.json
git commit -m "fix: sync package-lock.json"
3. Missing Dependencies
Error:
Cannot find module '@dnd-kit/core'
Cannot find module 'vitest'
Solution: Install missing packages:
npm install @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities --save-dev
4. TypeScript Type Errors
Common patterns:
Checkbox Import Issue
const { CheckboxGroup } = Checkbox;
const CheckboxGroup = Checkbox.Group;
Snake vs Camel Case
interface AnalyticsConfig {
chart_type: 'line' | 'bar';
time_range: [string, string];
group_by?: string;
}
Dayjs vs Date in DatePicker
value={[new Date(config.time_range[0]), new Date(config.time_range[1])]}
import dayjs from 'dayjs';
value={[dayjs(config.time_range[0]), dayjs(config.time_range[1])]}
Possibly Undefined
label={({ percent }) => `${(percent * 100).toFixed(0)}%`}
label={({ percent }) => `${((percent || 0) * 100).toFixed(0)}%`}
5. Test Configuration Issues
Error:
No tests found, exiting with code 1
Cause: Test script paths don't match actual test file locations.
Solution: Fix package.json scripts:
{
"test:unit": "jest --coverage=false --passWithNoTests",
"test:integration": "jest --coverage=false --passWithNoTests"
}
6. E2E Tests Failing in CI
Error: Tests fail because backend API is not available.
Cause: E2E tests require running backend server.
Solution: Skip E2E tests in CI, run locally:
GitHub Actions Best Practices
Node.js Version
- Use consistent Node version locally and in CI
- Check with
node --version
- Update workflows to match
Package Manager
- Use same package manager locally and in CI
- If using npm, don't reference pnpm-lock.yaml
- If lock file is missing, run
npm install to generate
Test Scripts
- Always add
--passWithNoTests to avoid CI failures when no tests match
- Verify test paths exist before committing
Workflow Structure
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci
- run: npm run lint:check
type-check:
test:
build:
needs: [lint, type-check, test]
Files to Check When CI Fails
.github/workflows/*.yml - CI configuration
package.json - Scripts and dependencies
package-lock.json - Lock file sync
tsconfig.json - TypeScript config
jest.config.js - Test configuration
Quick Fix Commands
npm install
npm run type-check
npm test
npm run build
rm -rf node_modules
npm install