Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change nodejs file to 14 in buildspec for codebuild?

Here is my buildspec.yml file used by codebuild:

version: 0.2
env:
  shell: bash
phases:
  install:
    runtime-versions:
      nodejs: 14
   pre_build:
    commands:
      - echo Installing source NPM dependencies...
      - npm install -g aws-cdk
      - npm install -g typescript
      - npm install
      - npm run build 

  build:
    commands:
      - cdk --version 
      - cdk ls
      - cdk synth 
  post_build:

/usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">= 14.15.0"} (current: {"node":"12.22.2","npm":"6.14.13"}) npm WARN notsup Not compatible with your version of node/npm: [email protected]

Finally, cdk ls fails

Appreciate any help as I have already tried removing node-modules and package-lock.json.

like image 325
Judi Avatar asked Dec 29 '25 13:12

Judi


1 Answers

In addition to setting the runtime-version in the buildspec, set the CodeBuild Project's environment prop to a build image type that supports Node 14. Currently, only Ubuntu Standard:5 does.

new codebuild.Project(this, 'MyBuildProject', {
  environment: {
    buildImage: codebuild.LinuxBuildImage.STANDARD_5_0,
  },
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      install: {
        'runtime-versions': {
          nodejs: '14.x',
        },
like image 80
fedonev Avatar answered Jan 01 '26 05:01

fedonev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!