这是我的 Angular5 项目结构。
tsconfig.app.json
和package.json
都包含这个部分
"include": [
"/src/main.ts",
"/src/polyfills.ts"
]
但是无论我怎么尝试,我仍然会得到这个错误:
\polyfills.ts & \main.ts is missing from the TypeScript compilation.
Please make sure it is in your tsconfig via the 'files' or 'include' property.
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"
]
}
最佳答案
找到解决方案。问题是因为我在符号链接(symbolic link)目录中($HOME/dev -> d:\dev\) 移至原始目录 (d:\dev) 并运行您的命令,一切正常。
关于TypeScript 编译中缺少 Angular5 :polyfills. ts &\main.ts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49091956/