I encountered a problem in an angular project I am working on where the karma.config was missing. To resolve this, I manually added it and attempted to run the test using the command ng test
. However, during the execution, an error message appeared:
[./src/polyfills.ts] 699 bytes {polyfills} [built] [failed] [1 error]
[./src/test.ts] 990 bytes {main}
+ 228 hidden modules
ERROR in ./src/polyfills.ts
Module build failed: Error: C:\Projects\MyProject\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (C:\C:\Projects\MyProject\node_modules\@ngtools\webpack\src\packages\ngtools\webpack\src\angular_compiler_plugin.ts:982:15)
at plugin.done.then (C:\Projects\MyProject\node_modules\@ngtools\webpack\src\packages\ngtools\webpack\src\loader.ts:49:29)
at process._tickCallback (internal/process/next_tick.js:68:7)
@ multi ./src/polyfills.ts
Upon investigation, I found that there are two tsconfig.json files in the app. The first one is located in the project's root folder with the following content:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
// other options here
}
}
The second tsconfig.json file is inside the src folder and includes:
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "es5",
"allowJs": true
}
}
Despite attempting to use the "include" directive in these files to add src/polyfills.ts, the issue persisted.
If anyone has insights on how to address this, please provide guidance. The Angular version being used is 6.