Cumulocity Web SDK - Angular CLI

What product/components do you use and which version/fix level are you on?

"@angular/animations": "~11.2.14",
"@angular/cdk": "~11.2.0",
"@angular/common": "~11.2.14",
"@angular/compiler": "~11.2.14",
"@angular/core": "~11.2.14",
"@angular/forms": "~11.2.14",
"@angular/platform-browser": "~11.2.14",
"@angular/platform-browser-dynamic": "~11.2.14",
"@angular/router": "~11.2.14",
"@c8y/cli": "^1011.47.0",

Is your question related to the free trial, or to a production (customer) instance?

trial

What are you trying to achieve? Please describe it in detail.

I’m trying to run a pure Angular project for Cumulocity as described on Cumulocity Web SDK Guide. I’m using Angular v11 lts which is stated in the guide is supported as of c8y version 10.10.4.0.
However, when I try to run it the below error appears. I have tried to fix it by changing the options in my angular.json as recommended in some forums. However this has only led to other errors. What might be the issue here? Could this be related to my Node version (currently an older version, v.12.11.1)? Any help would be appreciated.

Do you get any error messages? Please provide a full error message screenshot and log file.

Error:
An unhandled exception occurred: The 'buildOptimizer' option cannot be used without 'aot'.

Logfile:

[error] Error: The 'buildOptimizer' option cannot be used without 'aot'.
    at generateWebpackConfig (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\src\utils\webpack-browser-config.js:16:15)
    at generateBrowserWebpackConfigFromContext (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\src\utils\webpack-browser-config.js:136:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.generateI18nBrowserWebpackConfigFromContext (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\src\utils\webpack-browser-config.js:77:20)
    at async setup (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:87:47)

angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "test": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@c8y/cli:build",
          "options": {
            "outputPath": "dist/test",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": false,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@c8y/cli:dev-server",
          "options": {
            "browserTarget": "test:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "test:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "test:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "test:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "test:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "test"
}

Have you installed all the latest fixes for the products and systems you are using?

Set aot and buildOptimizer to true.

Thanks for your answer!
I have already tried that as it is suggested in a few stackoverflow posts, but it leads to the next error, for which I have not found any information:
An unhandled exception occurred: Cannot read property 'tap' of undefined

log:

[error] TypeError: Cannot read property 'tap' of undefined
    at HtmlWebpackPlugin.apply (C:\Users\wern\Documents\AngularProjects\test\node_modules\html-webpack-plugin\index.js:40:31)
    at C:\Users\wern\Documents\AngularProjects\test\node_modules\@c8y\cli\dist\webpack\plugin\plugin.js:263:29
    at Array.forEach (<anonymous>)
    at CumulocityPlugin.applyOtherPlugins (C:\Users\wern\Documents\AngularProjects\test\node_modules\@c8y\cli\dist\webpack\plugin\plugin.js:263:14)
    at CumulocityPlugin.apply (C:\Users\wern\Documents\AngularProjects\test\node_modules\@c8y\cli\dist\webpack\plugin\plugin.js:41:14)
    at Object.webpack [as webpackFactory] (C:\Users\wern\Documents\AngularProjects\test\node_modules\webpack\lib\webpack.js:51:13)
    at createWebpack (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:21:36)
    at Object.runWebpackDevServer (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:47:12)
    at SwitchMapSubscriber.project (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:221:32)
    at SwitchMapSubscriber._next (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\switchMap.js:47:27)
    at SwitchMapSubscriber.Subscriber.next (C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\Subscriber.js:66:18)
    at C:\Users\wern\Documents\AngularProjects\test\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\util\subscribeToPromise.js:7:24
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.