Known Issue– If the newest NodeJS LTS version is out of sync with AWS CodeBuild, BaaS service build

This issue was originally published earlier this year, on the previous forum platform:   

Issue description:  

After downloading the most recent NodeJS LTS release, BaaS NodeJS service build fails with npm errors. This is an environmental issue, applicable to any version of Backend as a Service.

Cause:  

The local NodeJS or npm version might not be compatible with the versions currently deployed in the AWS CodeBuild image.  

For example, as of April 10, 2024, the latest NodeJS 20 LTS release is 20.12.2 includes npm 10.5, whereas the current AWS CodeBuild image NodeJS 20 v7.0 includes NodeJS 20.11.1 and npm 10.2.4, causing an  npm error: “ENOTCACHED”.  


An example of a build log:    

Workaround:  

Ensure that the local versions correspond to the server versions. The local environment must be adjusted, as the timing of all updates of the AWS CodeBuild images to new NodeJS LTS releases is governed by AWS. 

  1. Assess the service build log to identify the exact NodeJS and npm versions currently used in AWS CodeBuild.
  2. Go to  https://nodejs.org  and install the matching versions of NodeJS/npm on your local machine.
  3. Run the Build and Deploy command for your NodeJS service once more. 


As of August 15 2024, the AWS Codebuild image for NodeJS20  includes npm 10.7.0. If you encounter npm error: ENOTCACHED when running Build and Deploy, consider these steps:

  1. Install the latest version of NodeJS20  from Node.js — Run JavaScript Everywhere (nodejs.org).
  2. Install the corresponding npm version, in this case:      npm install -g npm@10.7.0
    At the time of writing, NodeJS 20.16.0 has been verified with npm 10.7.0. 
  3. In Service Explorer, right-click the service and select Update Framework to clear the cache.
  4. Right-click the service and select Build and Deploy.