2

I have an angular app. I am trying to do CICD from GitHub using aws code-pipeline. In my buildspec.yml file, I have the following commands.

phases:
  install:
    commands:
      - echo installing nodejs...
      - curl -sL https://deb.nodesource.com/setup_14.x | bash -
      - apt-get install -y nodejs #aws code build use ubuntu environement
      - which nodejs
      - which node
      - node -v
      - sudo npm install -g n
      - sudo n latest
      - node -v

I am installing nodejs 14 version. After I do so, I will install the angular cli.

#   pre_build:
#     commands:
#       - echo installing dependencies...
#       - npm i -g @angular/cli
#       - npm install

And then I am trying to build the app. Command - node -v gives my 12.22.12 version. Command nodejs -v gives my 14.x version that I installed. But my ng build isn't successful. I am getting below error.

[Container] 2022/08/02 03:39:48 Running command ng build
Node.js version v12.22.12 detected.
The Angular CLI requires a minimum Node.js version of either v14.15, or v16.10.

Please update your Node.js version or visit https://nodejs.org/ for additional instructions.


[Container] 2022/08/02 03:39:48 Command did not exit successfully ng build exit status 3
[Container] 2022/08/02 03:39:48 Phase complete: BUILD State: FAILED
[Container] 2022/08/02 03:39:48 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: ng build. Reason: exit status 3

I tried to update the legacy node version in ubuntu using most of the StackOverflow links. Nothing works. Please help me.

LJR
  • 151
  • 10
  • 1
    Even after installing node 14.x version, why does the ubuntu uses the node 12.x version ? – LJR Aug 02 '22 at 04:04

1 Answers1

0

Try running n 14.18.3.

The n package is pre-installed on (at least some) CodeBuild runtimes which you can use to install another version and select among installed versions.

Details here.

Rajesh Lohith
  • 426
  • 3
  • 10