Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng build : Workspace config file cannot be loaded

When I run the ng build command I receive following error,

An unhandled exception occurred: Workspace config file cannot be loaded: C:...\angular\angular.json Invalid JSON character: "" at 0:0. See "C:\Users...\AppData\Local\Temp\ng-I8pYWt\angular-errors.log" for further details.

I have tried npm cache clean --force then npm install or yarn

angular-errors.log

[error] Error: Workspace config file cannot be loaded: C:\...\angular\angular.json
Invalid JSON character: "" at 0:0.
at Object.getWorkspace (C:\...\angular\node_modules\@angular\cli\utilities\config.js:59:15)
at BuildCommand.validateScope (C:\...\angular\node_modules\@angular\cli\models\command.js:97:60)
at BuildCommand.validateAndRun (C:\...\angular\node_modules\@angular\cli\models\command.js:122:24)
at Object.runCommand (C:\...\angular\node_modules\@angular\cli\models\command-runner.js:186:38)
at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:52:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:880:11)
at internal/main/run_main_module.js:21:11

version

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.6
@angular-devkit/build-angular     0.800.6
@angular-devkit/build-optimizer   0.800.6
@angular-devkit/build-webpack     0.800.6
@angular-devkit/core              8.3.9
@angular-devkit/schematics        8.3.9
@angular/cdk                      8.2.3
@angular/cli                      8.3.9
@ngtools/webpack                  8.0.6
@schematics/angular               8.3.9
@schematics/update                0.803.9
rxjs                              6.4.0 (cli-only)
typescript                        3.4.5
webpack                           4.30.0

angular.json

{
  "$schema": "../node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "abp-zero-template": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.json",
            "polyfills": "src/polyfills.ts",
            "preserveSymlinks": true,
            "assets": [
              "src/assets",
              "src/metronic",
              "src/favicon.ico",
              {
                "glob": "abp.signalr-client.js",
                "input": "node_modules/abp-web-resources/Abp/Framework/scripts/libs",
                "output": "/assets/abp"
              }
            ],
            "styles": [
              "node_modules/animate.css/animate.min.css",
              "node_modules/quill/dist/quill.core.css",
              "node_modules/quill/dist/quill.snow.css",
              "node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",
              "node_modules/primeng/resources/primeng.min.css",
              "node_modules/primeng/resources/themes/nova-light/theme.css",
              "node_modules/primeicons/primeicons.css",
              "node_modules/sweetalert2/dist/sweetalert2.css",
              "node_modules/cookieconsent/build/cookieconsent.min.css",
              "src/assets/FreezeUI/freeze-ui.min.css",

              "src/assets/primeng/file-upload/css/primeng.file-upload.css",
              "src/assets/primeng/autocomplete/css/primeng.autocomplete.css",
              "src/assets/primeng/tree/css/primeng.tree.css",
              "src/assets/primeng/context-menu/css/primeng.context-menu.css",

              "src/assets/fonts/fonts-poppins.css",
              "src/assets/fonts/fonts-roboto.css",

              "src/assets/ngx-bootstrap/bs-datepicker.css",

              "src/assets/metronic/vendors/global/vendors.bundle.css",

              "src/app/shared/core.less",
              "src/app/shared/layout/layout.less",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
              "node_modules/localforage/dist/localforage.js",
              "node_modules/moment/min/moment-with-locales.js",
              "node_modules/moment-timezone/builds/moment-timezone-with-data.js",
              "node_modules/push.js/bin/push.js",
              "node_modules/quill/dist/quill.js",
              "node_modules/sweetalert2/dist/sweetalert2.js",
              "node_modules/cookieconsent/build/cookieconsent.min.js",

              "src/assets/FreezeUI/freeze-ui.js",

              "src/assets/abp-web-resources/abp.js",
              "src/assets/abp-web-resources/abp.sweet-alert.js",
              "src/assets/abp-web-resources/abp.notify.js",
              "src/assets/abp-web-resources/abp.freeze-ui.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js",

              "src/assets/metronic/vendors/global/vendors.bundle.js",
              "src/assets/metronic/common/js/scripts.bundle.js"
            ]
          },
          "configurations": {
            "hmr": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.hmr.ts"
                }
              ]
            },
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "abp-zero-template:build"
          },
          "configurations": {
            "hmr": {
              "browserTarget": "abp-zero-template:build:hmr"
            },
            "production": {
              "browserTarget": "abp-zero-template:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "abp-zero-template:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "tsConfig": "src/tsconfig.json",
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "styles": [
              "node_modules/animate.css/animate.min.css",
              "node_modules/quill/dist/quill.core.css",
              "node_modules/quill/dist/quill.snow.css",
              "node_modules/famfamfam-flags/dist/sprite/famfamfam-flags.css",
              "node_modules/primeng/resources/primeng.min.css",
              "node_modules/primeng/resources/themes/nova-light/theme.css",
              "node_modules/primeicons/primeicons.css",
              "node_modules/sweetalert2/dist/sweetalert2.css",
              "node_modules/cookieconsent/build/cookieconsent.min.css",
              "src/assets/FreezeUI/freeze-ui.min.css",

              "src/assets/primeng/file-upload/css/primeng.file-upload.css",
              "src/assets/primeng/autocomplete/css/primeng.autocomplete.css",
              "src/assets/primeng/tree/css/primeng.tree.css",
              "src/assets/primeng/context-menu/css/primeng.context-menu.css",

              "src/assets/fonts/fonts-poppins.css",
              "src/assets/fonts/fonts-roboto.css",

              "src/assets/ngx-bootstrap/bs-datepicker.css",

              "src/assets/metronic/vendors/global/vendors.bundle.css",

              "src/app/shared/core.less",
              "src/app/shared/layout/layout.less",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/@aspnet/signalr/dist/browser/signalr.min.js",
              "node_modules/localforage/dist/localforage.js",
              "node_modules/moment/min/moment-with-locales.js",
              "node_modules/moment-timezone/builds/moment-timezone-with-data.js",
              "node_modules/push.js/bin/push.js",
              "node_modules/quill/dist/quill.js",
              "node_modules/sweetalert2/dist/sweetalert2.js",
              "node_modules/cookieconsent/build/cookieconsent.min.js",
              "src/assets/FreezeUI/freeze-ui.js",

              "src/assets/abp-web-resources/abp.js",
              "src/assets/abp-web-resources/abp.sweet-alert.js",
              "src/assets/abp-web-resources/abp.notify.js",
              "src/assets/abp-web-resources/abp.freeze-ui.js",
              "node_modules/abp-web-resources/Abp/Framework/scripts/libs/abp.moment.js",

              "src/assets/metronic/vendors/global/vendors.bundle.js",
              "src/assets/metronic/common/js/scripts.bundle.js"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico",
              {
                "glob": "abp.signalr-client.js",
                "input": "node_modules/abp-web-resources/Abp/Framework/scripts/libs",
                "output": "/assets/abp"
              }
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.json"
            ],
            "exclude": []
          }
        }
      }
    },
    "abp-zero-template-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "abp-zero-template:serve",
            "port": 4200
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.json"
            ],
            "exclude": []
          }
        }
      }
    }
  },
  "defaultProject": "abp-zero-template",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "css"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}
like image 711
Aqeel Qureshi Avatar asked Jan 25 '23 17:01

Aqeel Qureshi


1 Answers

Make sure the angular.json file encoding is UTF-8.

like image 130
Hsuan Lee Avatar answered Jan 28 '23 10:01

Hsuan Lee