简体   繁体   中英

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.

"resolveJsonModule": true, "esModuleInterop": true,

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 ).

Typescript add esModuleInterop in version 2.7 ( official doc ).

As Typescript 2.9 is used from Angular 7, I don't know if you can update Typescript.

Maybe try another way like in this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM