Home > Software design >  TypeError: Cannot read property 'write' of undefined, Angular app built on AWS CodeBuild
TypeError: Cannot read property 'write' of undefined, Angular app built on AWS CodeBuild

Time:07-28

I have an Angular app being build on AWS CodeBuild getting the error

/codebuild/output/src880653465/src/node_modules/@angular/cli/ember-cli/lib/ui/index.js:56 this.outputStream.write(data); ^

TypeError: Cannot read property 'write' of undefined at UI.write (/codebuild/output/src880653465/src/node_modules/@angular/cli/ember-cli/lib/ui/index.js:56:23) at UI.writeLine (/codebuild/output/src880653465/src/node_modules/@angular/cli/ember-cli/lib/ui/index.js:69:8)

I've seen this error has been talked about here before but none of the accepted answers worked for my case. I tried all manner of npm update -g @angular/cli and targeting different versions or other manners of installing/updated angular, all to no avail

The app is being build via the following yml on AWS CodeBuild

   runtime-versions:
        nodejs: 14
    commands:
        - echo installing...
        - npm install -g @angular/cli
        - npm install
  build:
    commands:
        - echo build 
        - ng build

The error happens during the build step ng build

Installed versions from CodeBuild are

 copying : node/14.19.2
 installed : v14.19.2 (with npm 6.14.17)

My package.json has angular at version 6 @angular/core": "6.1.0", yet CodeBuild shows the below note

Your global Angular CLI version (14.1.0) is greater than your local version (1.7.4). The local Angular CLI version is used.

Tried a few other random things like settings TypeScript versions or more ways of modifying Node or Angular version, all same results

Any ideas what I'm doing wrong to cause this odd TypeScript error? or what versions are mismatched that I can correct?

CodePudding user response:

Try installing this specific version of Angular CLI. Instead of

    commands:
        - echo installing...
        - npm install -g @angular/cli

specify exactly

    commands:
        - echo installing...
        - npm install -g @angular/[email protected]
  • Related