Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating to Angular 10 error: Failed to parse "tsconfig.json" as JSON AST Object

I'm trying to update Angular 9 app to Angular 10 and get an error:

> Removing "Solution Style" TypeScript configuration file support.
× Migration failed: Failed to parse "tsconfig.json" as JSON AST Object. PropertyNameExpected at location: 571.
  See "C:\Users\F11K\AppData\Local\Temp\ng-T8Bgiu\angular-errors.log" for further details.

That's the content of the log file:

[error] Error: Failed to parse "tsconfig.json" as JSON AST Object. PropertyNameExpected at location: 571.
    at JSONFile.get JsonAst [as JsonAst] (C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\utility\json-file.js:33:19)
    at JSONFile.get (C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\utility\json-file.js:41:61)
    at C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\migrations\update-10\remove-solution-style-tsconfig.js:33:71
    at MergeMapSubscriber.project (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\rules\call.js:75:24)
    at MergeMapSubscriber._tryNext (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:67:27)
    at MergeMapSubscriber._next (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:57:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Subscriber.js:66:18)
    at Observable._subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeToArray.js:5:20)
    at Observable._trySubscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:30:22)
    at MergeMapOperator.call (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:37:23)
    at Observable.subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:25:31)
    at MapOperator.call (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\map.js:32:23)
    at Observable.subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:25:31)
    at Object.innerSubscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\innerSubscribe.js:102:23)
    at MergeMapSubscriber._innerSub (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:80:50)

[error] Error: Failed to parse "tsconfig.json" as JSON AST Object. PropertyNameExpected at location: 571.
    at JSONFile.get JsonAst [as JsonAst] (C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\utility\json-file.js:33:19)
    at JSONFile.get (C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\utility\json-file.js:41:61)
    at C:\Users\F11K\Documents\server\angular-client\node_modules\@schematics\angular\migrations\update-10\remove-solution-style-tsconfig.js:33:71
    at MergeMapSubscriber.project (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\rules\call.js:75:24)
    at MergeMapSubscriber._tryNext (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:67:27)
    at MergeMapSubscriber._next (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:57:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Subscriber.js:66:18)
    at Observable._subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\util\subscribeToArray.js:5:20)
    at Observable._trySubscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:30:22)
    at MergeMapOperator.call (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:37:23)
    at Observable.subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:25:31)
    at MapOperator.call (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\map.js:32:23)
    at Observable.subscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\Observable.js:25:31)
    at Object.innerSubscribe (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\innerSubscribe.js:102:23)
    at MergeMapSubscriber._innerSub (C:\Users\F11K\AppData\Local\Temp\angular-cli-packages-dD436h\node_modules\@angular\cli\node_modules\rxjs\internal\operators\mergeMap.js:80:50)

I've looked into the tsconfig.json and manually adjusted: "module": "esnext" => "module": "es2020" but it didn't work.

Log confusing me as it's not gets me right place where error occurs, could you please help? Thanks a lot.

Content of tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "downlevelIteration": true,
    "incremental": true,
    "tsBuildInfoFile": ".tsbuildinfo",
    "module": "es2020",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types",
      "tests"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "baseUrl": "src",
  }
}
like image 907
Platon Rov Avatar asked Sep 14 '20 15:09

Platon Rov


2 Answers

Removing an unnecessary "," worked for me. In yours the problem could be solved by removing the "," after "baseUrl": "src"

like image 191
Leo Filippelli Avatar answered Oct 17 '22 12:10

Leo Filippelli


Angular "ng update" have an integrated JSON linter and if you have a JSON with a comma or with a weird format or something it will throw an error. You can use jsonlint.com provided by @heretic-monkey and fix your JSON file first.

PS: I tried --force, -migrateOnly nothing worked, I just had a comma at end of my 'lib' array { "lib": [ "es2017", "dom" ], }

like image 6
iulian Avatar answered Oct 17 '22 12:10

iulian