我正在尝试创建一个新的 Angular 5 项目。我已经安装了@angular/cli 版本 1.6.3 并输入:
ng new project --routing
安装完所有东西后我做了:
cd project
ng build
并得到以下错误:
Module build failed: Error: d:...\project\src\main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
Module build failed: Error: d:...\project\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
在 Angular github page 上有几个关于这个的讨论。 ,但除了说这已经解决,或者指出 node_modules
中的 ts
文件的问题之外 - 它没有帮助。
我们在这里使用的是 Windows 10。
编辑:tsconfig 文件是(有两个):
{
"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": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
这些都是由 ng new
创建的。
最佳答案
天哪,我忘了回答这个问题!很久以前在 Angular github 上已经回答过了。
在 Angular 5 中,您需要将 --preserve-symlinks
添加到 ng build
和 ng serve
中。
在 Angular 6 中你不能再这样做了,你需要添加
"preserveSymlinks": true,
对于angular.json
,你把它放在项目的architect/build/options
下。
关于angular - 无法使用 angular-cli 创建 Angular 5 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48148375/