question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker: [error] TypeError: Cannot read property 'Workspace' of undefined

See original GitHub issue

Hello i have been experimenting this error when building on a docker image for quite some time now. I have also been trying different versions of angular dependencies around angular 12.

The error:

[error] TypeError: Cannot read property ‘Workspace’ of undefined at Object.getWorkspace (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/utilities/config.js:66:57) at BuildCommand.validateScope (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/models/command.js:97:67) at BuildCommand.validateAndRun (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/models/command.js:122:24) at Object.runCommand (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/models/command-runner.js:201: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:623:3)

🐞 Bug report

  • new
  • [x ] build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

It seems to work with version 9

Description

The error happens when building on a docker image with a bitbucket pipeline. It does work when building on a windows local machine with the command: ng build --configuration=production && ng run safesante-ysera-front:server --configuration=production && npm run pack

🔬 Minimal Reproduction

ng build --configuration=production && ng run safesante-ysera-front:server --configuration=production && npm run pack

with the following configuration:

{ “version”: 1, “newProjectRoot”: “projects”, “projects”: { “safesante-ysera-front”: { “root”: “”, “sourceRoot”: “src”, “projectType”: “application”, “prefix”: “app”,

  "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/safesante-ysera-front",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.app.json",
        "assets": [
          "src/favicon.ico",
          "src/assets",
          {
            "glob": "**/*",
            "input": "node_modules/ngx-extended-pdf-viewer/assets/",
            "output": "/assets/"
          }
        ],
        "styles": [
          "node_modules/font-awesome/css/font-awesome.min.css",
          "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
          "node_modules/font-awesome-animation/dist/font-awesome-animation.css",
          "node_modules/font-awesome-animation/dist/font-awesome-animation.min.css",
          "node_modules/weather-icons/css/weather-icons.min.css",
          "design/css/fullcalendar-vendor.min.css",
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "node_modules/angular2-multiselect-dropdown/themes/default.theme.css",
          "src/material-icons-font-face.scss",
          "src/ysera-styles-caro.css",
          "src/ysera-styles-faycal.css",
          "src/ysera-styles-max.css",
          "src/styles.scss"
        ],
        "scripts": [
          "./node_modules/jquery/dist/jquery.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.min.js",
          "./node_modules/detectrtc/DetectRTC.js",
          "src/assets/picture-in-picture.js",
          "src/assets/lib-jitsi-meet/lib-jitsi-meet.min.js",
          "./node_modules/fast-levenshtein/levenshtein.js",
          "node_modules/@fortawesome/fontawesome-free/js/all.min.js"
        ],
        "vendorChunk": true,
        "extractLicenses": false,
        "buildOptimizer": false,
        "aot": true,
        "sourceMap": true,
        "optimization": false,
        "namedChunks": true
      },
      "configurations": {
        "production": {
          "budgets": [],
          "index": {
            "input": "src/index.production.html",
            "output": "index.html"
          },
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "assets": [
            "src/favicon.ico",
            "src/assets",
            {
              "glob": "**/*",
              "input": "node_modules/ngx-extended-pdf-viewer/assets/",
              "output": "/assets/"
            },
            {
              "glob": "Procfile",
              "input": "src/",
              "output": "./"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "namedChunks": false,
          "extractLicenses": true,
          "vendorChunk": false,
          "aot": true,
          "buildOptimizer": true
        },
        "development": {
          "budgets": []
        },
        "remote": {
          "budgets": [],
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.remote.ts"
            }
          ]
        }
      },
      "defaultConfiguration": ""
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "safesante-ysera-front:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "safesante-ysera-front:build:production",
          "proxyConfig": "proxy-production.config.json"

        },
        "development": {
          "browserTarget": "safesante-ysera-front:build:development",
          "proxyConfig": "proxy-development.config.json"
        },
        "remote": {
          "browserTarget": "safesante-ysera-front:build:remote",
          "proxyConfig": "proxy-remote.config.json"
        }
      }
    },
    "extract-i18n": {
      "builder": "@angular-devkit/build-angular:extract-i18n",
      "options": {
        "browserTarget": "safesante-ysera-front:build"
      }
    },
    "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
        "main": "src/test.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.spec.json",
        "karmaConfig": "src/karma.conf.js",
        "styles": [
          "src/styles.css"
        ],
        "scripts": [],
        "assets": [
          "favicon.png",
          "src/assets",
          {
            "glob": "**/*",
            "input": "node_modules/ngx-extended-pdf-viewer/assets/locale",
            "output": "/assets/locale/"
          }
        ]
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "src/tsconfig.app.json",
          "src/tsconfig.spec.json"
        ],
        "exclude": [
          "**/node_modules/**"
        ]
      }
    },
    "server": {
      "builder": "@angular-devkit/build-angular:server",
      "options": {
        "outputPath": "dist/safesante-ysera-server",
        "main": "server.ts",
        "tsConfig": "src/tsconfig.server.json",
        "sourceMap": true,
        "optimization": false
      },
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ]
        }
      },
      "assets": [
        {
          "input": "src/Procfile",
          "output": "./"
        }
      ],
      "defaultConfiguration": ""
    },
    "serve-ssr": {
      "builder": "@nguniversal/builders:ssr-dev-server",
      "options": {
        "browserTarget": "safesante-ysera-front:build",
        "serverTarget": "safesante-ysera-front:server"
        
      },
      "configurations": {
        "production": {
          "browserTarget": "safesante-ysera-front:build:production",
          "serverTarget": "safesante-ysera-front:server:production",
          "proxyConfig": "proxy-production.config.json"
        }
      }
    },
    "prerender": {
      "builder": "@nguniversal/builders:prerender",
      "options": {
        "browserTarget": "safesante-ysera-front:build:production",
        "serverTarget": "safesante-ysera-front:server:production",
        "routes": [
          "/"
        ]
      },
      "configurations": {
        "production": {}
      }
    }
  }
},
"safesante-ysera-front-e2e": {
  "root": "e2e/",
  "projectType": "application",
  "architect": {
    "e2e": {
      "builder": "@angular-devkit/build-angular:protractor",
      "options": {
        "protractorConfig": "e2e/protractor.conf.js",
        "devServerTarget": "safesante-ysera-front:serve"
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": "e2e/tsconfig.e2e.json",
        "exclude": [
          "**/node_modules/**"
        ]
      }
    }
  }
}

}, “defaultProject”: “safesante-ysera-front”, “cli”: { “analytics”: false } }

🔥 Exception or Error

ng build --configuration=production && ng run safesante-ysera-front:server --configuration=production && npm run pack An unhandled exception occurred: Cannot read property ‘Workspace’ of undefined See “/tmp/ng-og2cCy/angular-errors.log” for further details. npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! safesante-ysera-front@0.0.9 build:ssr: ng build --configuration=production && ng run safesante-ysera-front:server --configuration=production && npm run pack npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the safesante-ysera-front@0.0.9 build:ssr script. npm ERR! This is probably not a problem with npm. There is likely additional logging output abov

and:

  • cat /tmp/*/angular-errors.log [error] TypeError: Cannot read property ‘Workspace’ of undefined at Object.getWorkspace (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/utilities/config.js:66:57) at BuildCommand.validateScope (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/models/command.js:97:67) at BuildCommand.validateAndRun (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/models/command.js:122:24) at Object.runCommand (/opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/models/command-runner.js:201: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:623:3)

🌍 Your Environment

Docker image: teracy/angular-cli

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hamzou247commented, Sep 23, 2021

Many thanks, after taking into account the above remarks, the pipeline is now working. You are awesome guys

1reaction
alan-agius4commented, Sep 22, 2021

Note: to update universal packages please use the below command.

ng update @nguniversal/express-engine
Read more comments on GitHub >

github_iconTop Results From Across the Web

SSH + Containers fails: TypeError: Cannot read properties of ...
Open a remote folder with Remote-SSH; Create Dockerfile, ... TypeError: Cannot read properties of undefined (reading 'groups') ...
Read more >
An unhandled exception occurred: Cannot read property ...
Try updating to latest versions of all the dependencies in package.json. I faced the same issue and spent 2 weeks finding the right...
Read more >
cannot read properties of undefined (reading 'collection')
Getting "TypeError: Cannot read property 'collection' of undefined" ... The error you're seeing is because variable dbo is not defined, as error suggests....
Read more >
Customize the Docker extension - Visual Studio Code
Reference for Docker build and Docker run tasks and properties in the Visual Studio Code Docker extension.
Read more >
Dockerizing an Angular App - Michael Herman
Hi, I'm getting `Uncaught TypeError: Cannot read property 'status' of undefined thrown` during docker is running the unit tests.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found