[英]error TS5023: Unknown compiler option 'compilerOptions'
我正在尝试将我的 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" ]
}
}
}
我该如何解决?
感谢支持
错误消息中提到的 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
将优先考虑typeRoots
而不是types
,并且所有包都将从"../node_modules/@types"
加载。 检查此链接以获取所有选项。
https://www.typescriptlang.org/docs/handbook/compiler-options.html
http://www.typescriptlang.org/docs/handbook/tsconfig-json.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.