问题
This is my Angular5 project structure.
Both tsconfig.app.json
and package.json
contain this section
"include": [
"/src/main.ts",
"/src/polyfills.ts"
]
But no matter what I try I still get this error:
\polyfills.ts & \main.ts is missing from the TypeScript compilation.
Please make sure it is in your tsconfig via the 'files' or 'include' property.
Anyone has idea what's missing here?
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
src/tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"include": [
"main.ts",
"polyfills.ts"
],
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
回答1:
Found the solution. The problem is because I was in a symbolic link directory ($HOME/dev -> d:\dev\ ) Move to the original directory (d:\dev) and run your commands and it works.
Source: https://github.com/angular/angular-cli/issues/9909
回答2:
It's possibly because you're using an absolute path.
Try changing from:
"/src/main.ts",
to
"src/main.ts",
(Or possibly just "main.ts"
)
回答3:
I also experienced this problem for a while, and I solved it by just changing the location of my project. I put it in the disk other than that of the system (example: d :, e: ...)
来源:https://stackoverflow.com/questions/49091956/angular5-polyfills-ts-main-ts-is-missing-from-the-typescript-compilation