[英]Angular 5 Service to read local .json file Error: Unknown compiler option 'resolveJsonModule' & 'esModuleInterop'
i need to import local json file in angular but it is not find json extension i already resolveJsonModule & 'esModuleInterop' to true in tsconfig.json got unknown compiler option. 我需要以角度导入本地json文件,但找不到json扩展名,我已经在tsconfig.json中将JsonModule和'esModuleInterop'解析为true,得到了未知的编译器选项。
"resolveJsonModule": true, "esModuleInterop": true, “ resolveJsonModule”:是,“ esModuleInterop”:是,
Node: 10.16.0
OS: win32 x64
Angular: 5.2.11
@angular/cdk: 5.2.5
@angular/cli: 1.7.4
@angular/material: 5.2.5
@angular/tsc-wrapped: 0.4.2
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
-------------------------------------------------------------------------------
tsconfig.json
-------------------------------------------------------------------------------
{
"compileOnSave": false,
"include": [
"./src"
],
"compilerOptions": {
"baseUrl": "./",
"outDir": "./Scripts/Angular/out-tsc",
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
}
}
Error:
-------------------------------------------------------------------------------
tsconfig.json(9,5): error TS5023: Unknown compiler option 'resolveJsonModule'.
tsconfig.json(10,5): error TS5023: Unknown compiler option 'esModuleInterop'
--------------------------------------------------------------------------------````
Typescript add resolveJsonModule
in version 2.9 but you are using typescript 2.5.3 ( official doc ). 打字稿在2.9版中添加resolveJsonModule
,但您正在使用打字稿2.5.3( 官方文档 )。
Typescript add esModuleInterop
in version 2.7 ( official doc ). 打字稿在2.7版中添加esModuleInterop
( 官方文档 )。
As Typescript 2.9 is used from Angular 7, I don't know if you can update Typescript. 由于从Angular 7使用Typescript 2.9,所以我不知道您是否可以更新Typescript。
Maybe try another way like in this answer . 也许喜欢尝试以另一种方式这个答案 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.