0

I need to install nodejs 20 as part of a build process running on codebuild.

Steps to reproduce

- sudo apt purge nodejs -y
- sudo apt-get install -y ca-certificates curl GnuPG
- export NODE_MAJOR=20
- sudo mkdir -p /etc/apt/keyrings
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
- sudo apt-get update && sudo apt-get install -y nodejs=20.8.0-1nodesource1
- echo "node version= $(node --version)"
- npm install -g npm

I am following the instructions described in nodejs distribution and specifying the nodejs version I want. Despite this, I keep installing nodejs 18 (from the source that comes with the image). I am using AWS image standard 7.0

Output from codebuild:

Preparing to unpack .../nodejs_20.8.0-1nodesource1_amd64.deb ...
Unpacking nodejs (20.8.0-1nodesource1) ...
Setting up nodejs (20.8.0-1nodesource1) ...

[Container] 2023/10/04 16:48:09 Running command echo "node version= $(node --version)" node version= v18.16.1

[Container] 2023/10/04 16:48:11 Running command sudo npm install -g npm npm ERR! code EBADENGINE npm ERR! engine Unsupported engine npm ERR! engine Not compatible with your version of node/npm: npm@10.2.0 npm ERR! notsup Not compatible with your version of node/npm: npm@10.2.0 npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"} npm ERR! notsup Actual: {"npm":"9.5.1","node":"v18.16.1"}

Joao Vitorino
  • 243
  • 1
  • 3
  • 10

1 Answers1

1

You can use buildspec.yml in the configuration use, you can use as follows

phases:
  install:
    runtime-versions:
      nodejs: 18. x
    commands:
      - n 20
Madan
  • 111
  • 2