<p>You can use buildspec.yml
in the configuration use, you can use as follows</p>
<pre><code>phases:
  install:
    runtime-versions:
      nodejs: 18. x
    commands:
      - n 20
</code></pre>

CC BY-SA 4.0
2023-12-07T03:21:14.417Z
2023-12-07T03:21:14.417Z
Madan
<p>I need to install nodejs 20 as part of a build process running on codebuild.</p>
<p>Steps to reproduce</p>
<pre><code>- 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 &quot;deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main&quot; | sudo tee /etc/apt/sources.list.d/nodesource.list
- sudo apt-get update &amp;&amp; sudo apt-get install -y nodejs=20.8.0-1nodesource1
- echo &quot;node version= $(node --version)&quot;
- npm install -g npm
</code></pre>
<p>I am following the instructions described in <a href="https://github.com/nodesource/distributions" rel="nofollow noreferrer">nodejs distribution</a> 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</p>
<p>Output from codebuild:</p>
<pre><code>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 &quot;node version= $(node --version)&quot;
**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: {&quot;node&quot;:&quot;^18.17.0 || &gt;=20.5.0&quot;}
npm ERR! notsup Actual:   {&quot;npm&quot;:&quot;9.5.1&quot;,&quot;node&quot;:&quot;v18.16.1&quot;}
</code></pre>

<node.js><ubuntu><aws-codepipeline>
Unable to install nodejs 20 in AWS codebuild image
Joao  Vitorino
# Unable to install nodejs 20 in AWS codebuild image

(Asked by: username_0 on 2023-10-04)

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"}

**Tags:** node.js, ubuntu, aws-codepipeline


---

## 1 answers

### Answer by username_1 on 2023-12-07. Score: 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


---

