gpt4 book ai didi

angular - 错误 TS5023 : Unknown compiler option 'compilerOptions'

转载 作者:太空狗 更新时间:2023-10-29 18:19:08 25 4
gpt4 key购买 nike

我正在尝试将我的 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

tsconfig.json

{
"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 将优先于此处的 types,并且所有包将从 "../node_modules/@types" 加载.检查此链接以了解所有选项。

https://www.typescriptlang.org/docs/handbook/compiler-options.html

http://www.typescriptlang.org/docs/handbook/tsconfig-json.html

关于angular - 错误 TS5023 : Unknown compiler option 'compilerOptions' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48789962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com