我正在尝试将Angular4应用程序更新为Angular5。
我尝试按照官方网站建议的程序,但现在我不能再编译,我收到此错误:
错误TS5023:未知的编译器选项'compilerOptions'。
这是组件的版本:
Angular CLI: 1.6.8
Node: 7.4.0
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.7.1
webpack: 3.10.0
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"types": [
"jquery",
"jqueryui",
"jasmine",
"datatables.net",
"datatables.net-select"
],
"compilerOptions": {
"types" : [ "node" ]
}
}
}
我该如何解决?
感谢支持
答案 0 :(得分:3)
错误消息中提到的tsconfig.json格式中存在错误。原始compilerOptions
对象中有一个额外的compilerOptions
属性。它应该像下面
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"types": [
"jquery",
"jqueryui",
"jasmine",
"datatables.net",
"datatables.net-select"
]
}
}
但是,typeRoots
将优先于types
,而不是"../node_modules/@types"
,所有包都将从.sln
加载。检查此链接是否包含所有选项。
https://www.typescriptlang.org/docs/handbook/compiler-options.html
http://www.typescriptlang.org/docs/handbook/tsconfig-json.html