with one click
e4-resolve-build-config
// Repair build and compiler configuration issues that block successful compilation.
// Repair build and compiler configuration issues that block successful compilation.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | e4-resolve-build-config |
| description | Repair build and compiler configuration issues that block successful compilation. |
When to use: Build process fails due to configuration issues
Purpose: Fix build system configuration to enable successful compilation.
Parse build output to determine issue type:
A. Missing file/directory
Cannot find file 'X'Entry module not found: 'X'B. Invalid syntax in config
Unexpected tokenJSON parse errorInvalid configurationC. Incompatible options
Option 'X' cannot be used with 'Y'Conflicting configurationD. Missing plugin/loader
Cannot find loader 'X'Plugin 'X' not foundE. Wrong path/pattern
No matching files for pattern 'X'Failed to resolve 'X'F. Version incompatibility
Requires version X but got YIncompatible peer dependencyIdentify which config file has the issue:
angular.json (Angular)webpack.config.js (Webpack)tsconfig.json (TypeScript)package.json (npm)vite.config.js (Vite)rollup.config.js (Rollup)Read the file to understand current settings.
Update file path in config:
{
"main": "src/main.ts" // Verify this file exists
}
Create missing file if needed:
Example tsconfig.json:
{
"files": [
"src/main.ts", // Ensure this exists
"src/polyfills.ts"
]
}
Common JSON errors:
Fix:
// Before (invalid):
{
"name": "app",
"version": "1.0.0", // ← Remove trailing comma before }
}
// After (valid):
{
"name": "app",
"version": "1.0.0"
}
Use JSON validator:
Check documentation for valid combinations:
Example TypeScript:
{
"compilerOptions": {
"module": "ES2022",
"target": "ES2022" // Must be compatible with module
}
}
Common valid combinations:
module: "ES2022" + target: "ES2022"module: "CommonJS" + target: "ES2020"module: "ESNext" + target: "ESNext"Install missing package:
# For webpack loaders:
npm install --save-dev ts-loader
npm install --save-dev css-loader style-loader
# For plugins:
npm install --save-dev html-webpack-plugin
npm install --save-dev copy-webpack-plugin
Add to config:
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader' // Now installed
}
]
}
};
Fix glob patterns:
{
"include": [
"src/**/*" // Recursive pattern
],
"exclude": [
"node_modules",
"dist"
]
}
Common patterns:
**/* - All files recursively*.ts - All .ts files in current dirsrc/**/*.ts - All .ts files under src**/*.spec.ts - All test filesFix file paths:
{
"compilerOptions": {
"outDir": "./dist", // Use correct relative path
"rootDir": "./src"
}
}
Update package versions:
// package.json
{
"devDependencies": {
"@angular/compiler-cli": "^17.0.0", // Update to compatible version
"typescript": "~5.2.0" // TypeScript version must be compatible
}
}
Check compatibility:
Reinstall:
npm install
{
"projects": {
"app-name": {
"architect": {
"build": {
"options": {
"outputPath": "dist/app-name", // Verify path
"index": "src/index.html", // File must exist
"main": "src/main.ts", // Entry point must exist
"tsConfig": "tsconfig.app.json" // Config must exist
}
}
}
}
}
}
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"lib": ["ES2022", "dom"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true, // Skip lib checking if needed
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
const path = require('path');
module.exports = {
entry: './src/index.ts', // Verify path
output: {
path: path.resolve(__dirname, 'dist'), // Absolute path
filename: 'bundle.js'
},
resolve: {
extensions: ['.ts', '.js'] // File extensions to resolve
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
}
};
Sometimes cached data causes issues:
# Clear Angular cache
rm -rf .angular/
# Clear TypeScript cache
rm -rf dist/
# Clear node_modules and reinstall
rm -rf node_modules
npm install
# Clear npm cache (if really stuck)
npm cache clean --force
After fixing configuration:
# Angular
ng build
ng build --configuration production
# TypeScript
tsc
tsc --build
# Webpack
npx webpack
npx webpack --mode production
# npm scripts (defined in package.json)
npm run build
Working build configuration with successful compilation.
Error:
Cannot find file 'src/main.ts'
Fix in angular.json:
{
"architect": {
"build": {
"options": {
"main": "src/main.ts" // Verify file exists at this path
}
}
}
}
Create file if missing:
// src/main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
Error:
Option 'module' must be 'CommonJS' when 'target' is 'ES3' or 'ES5'
Fix:
{
"compilerOptions": {
"target": "ES2020", // Update target
"module": "ES2020" // Now compatible
}
}
Error:
Module parse failed: Unexpected token
You may need an appropriate loader to handle this file type
Fix:
npm install --save-dev ts-loader
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader'
}
]
}
};