运行ng serve时出现以下错误

时间:2019-08-18 16:03:23

标签: json angular terminal internationalization

我是新手,VSCode有问题。运行ng serve时出现以下错误:


PS C:\Windows\System32\x-app> ng serve --configuration=it
An unhandled exception occurred: Workspace config file cannot le loaded: C:\Windows\System32\x-app\angular.json    
Invalid JSON character: "\"" at 73:7.
See "C:\Users\C-PROJ~1\AppData\Local\Temp\ng-LpcKJr\angular-errors.log" for further details

[error] Error: Workspace config file cannot le loaded: C:\Windows\System32\x-app\angular.json
Invalid JSON character: "\"" at 73:7.
    at Object.getWorkspace (C:\Windows\System32\x-app\node_modules\@angular\cli\utilities\config.js:59:15)
    at ServeCommand.validateScope (C:\Windows\System32\x-app\node_modules\@angular\cli\models\command.js:97:60)
    at ServeCommand.validateAndRun (C:\Windows\System32\x-app\node_modules\@angular\cli\models\command.js:122:24)
    at Object.runCommand (C:\Windows\System32\x-app\node_modules\@angular\cli\models\command-runner.js:185:38)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

我使用prettier,实际上,我注意到对内部化的疏忽。我修复了json文件,并返回了命令ng serve --configuration=it,但结果是另一个错误。


PS C:\Windows\System32\x-app> ng serve --configuration=it
An unhandled exception occurred: Project does not exist.
See "C:\Users\C-PROJ~1\AppData\Local\Temp\ng-IomfPN\angular-errors.log" for further details.

[error] Error: Project does not exist.
    at WorkspaceNodeModulesArchitectHost.findProjectTarget (C:\Windows\System32\x-app\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:94:23)
    at WorkspaceNodeModulesArchitectHost.getOptionsForTarget (C:\Windows\System32\x-app\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:66:33)
    at core_1.experimental.jobs.createJobHandler.target (C:\Windows\System32\x-app\node_modules\@angular-devkit\architect\src\architect.js:171:21)
    at Observable.rxjs_1.Observable.subject [as _subscribe] (C:\Windows\System32\x-app\node_modules\@angular-devkit\core\src\experimental\jobs\create-job-handler.js:91:26)
    at Observable._trySubscribe (C:\Windows\System32\x-app\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (C:\Windows\System32\x-app\node_modules\rxjs\internal\Observable.js:30:22)
    at C:\Windows\System32\x-app\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (C:\Windows\System32\x-app\node_modules\rxjs\internal\util\subscribeToResult.js:10:45)
    at SwitchMapSubscriber._innerSub (C:\Windows\System32\x-app\node_modules\rxjs\internal\operators\switchMap.js:65:54)
    at SwitchMapSubscriber._next (C:\Windows\System32\x-app\node_modules\rxjs\internal\operators\switchMap.js:55:14)
    at SwitchMapSubscriber.Subscriber.next (C:\Windows\System32\x-app\node_modules\rxjs\internal\Subscriber.js:66:18)
    at SwitchMapSubscriber.notifyNext (C:\Windows\System32\x-app\node_modules\rxjs\internal\operators\switchMap.js:86:26)
    at InnerSubscriber._next (C:\Windows\System32\x-app\node_modules\rxjs\internal\InnerSubscriber.js:28:21)
    at InnerSubscriber.Subscriber.next (C:\Windows\System32\x-app\node_modules\rxjs\internal\Subscriber.js:66:18)
    at MapSubscriber._next (C:\Windows\System32\x-app\node_modules\rxjs\internal\operators\map.js:55:26)
    at MapSubscriber.Subscriber.next (C:\Windows\System32\x-app\node_modules\rxjs\internal\Subscriber.js:66:18)

1 个答案:

答案 0 :(得分:0)

您的angular.json可能格式错误。请检查文件是否符合json标准。您可以使用prettier之类的工具来格式化json。