Unable to upgrade from nodejs 14 (platform 5.4.6) to nodejs 16 (platform 5.5.6)

0

I am trying to upgrade the nodejs version of the app on the platform as mentioned here however, I am getting the following error while deploying the app.

2022/09/30 16:17:23.581348 [ERROR] An error occurred during execution of command [app-deploy] - [Install customer specified node.js version]. Stop running the command. Error: the node.js version range >=16 <17 is not available for this platform. Please choose a version matching one of the following: [v14.0.0 v14.1.0 v14.2.0 v14.3.0 v14.4.0 v14.5.0 v14.6.0 v14.7.0 v14.8.0 v14.9.0 v14.10.0 v14.10.1 v14.11.0 v14.12.0 v14.13.0 v14.13.1 v14.14.0 v14.15.0 v14.15.1 v14.15.2 v14.15.3 v14.15.4 v14.15.5 v14.16.0 v14.16.1 v14.17.0 v14.17.1 v14.17.2 v14.17.3 v14.17.4 v14.17.5 v14.17.6 v14.18.0 v14.18.1 v14.18.2 v14.18.3 v14.19.0 v14.19.1 v14.19.2 v14.19.3 v14.20.0] 

According to this platform 5.5.6 should support nodejs and defining the engine range as the following should use the latest nodejs 16 version available to the platform

{
    ...
    "engines": { "node" : ">=16 <17" }
  }
asked 2 years ago276 views
1 Answer
0

Hello,

The problem is caused by the change in npm version; there was a breaking change between npm v6 (Node.js 14) and npm v8 (Node.js 16) relating to filesystem permissions.

Solution:

  1. Create the following Platform Hooks paths in the root directory of your application bundle.
  • .platform/hooks/prebuild
  • .platform/confighooks/prebuild
  1. Create the following bash script (00_npm_install.sh) with execute permissions (chmod +x).

#!/bin/bash cd /var/app/staging sudo -u webapp npm install sharp

  1. Validate the Application Bundle Structure.

Example Sample project structure:

~/my-app/

├── app.js

├── index.html

├── .npmrc_bkp

├── package.json

├── package-lock.json

├── .platform

│ ├── confighooks

│ │ └── prebuild

│ │ └── 00_npm_install.sh

│ └── hooks

│ └── prebuild

│ └── 00_npm_install.sh

└── Procfile

  1. Deploy the Application!

This solution is explained in more details on this post https://github.com/lovell/sharp/issues/3221#issuecomment-1126528844

AWS
SUPPORT ENGINEER
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions