使用ng serve命令启动项目时出错

时间:2019-07-22 15:16:43

标签: angular visual-studio-code polyfills

我正在尝试使用ng serve命令启动我的项目,但出现了这些错误,

我试图缩短这条路,但对我没有用


Module build failed (from c:/users/xxx/node_modules/@ngtools/webpack/src/index.js):
pathxx\main.ts is missing from the TypeScript compilation. Please
make sure it is in your tsconfig via the 'files' or 'include' property

pathxx\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property

2 个答案:

答案 0 :(得分:0)

由于错误提示您tsconfig中没有main.ts和polyfills.ts,请添加它们:

//tsconfig

"files": ["./src/main.ts", "./src/polyfills.ts"]

答案 1 :(得分:0)

必须与您的tsconfig文件有关。

首先,我建议在根目录中运行tsc --extendedDiagnostics来检查TypeScript编译问题。

此外,这是一个可用的tsconfig文件的示例: { "compileOnSave": false, "compilerOptions": { "baseUrl": "./src", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "module": "es2015", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "importHelpers": true, "paths": { "@fuse": [ "@fuse/" ] }, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2018", "dom" ] } }

也许正在运行: ng lint 可以倒更多光