Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Node Version in Provision Step in Amplify Console

Tags:

I'm facing the problem that I cant build my Angular app through the AWS Amplify Console: "You are running version v8.12.0 of Node.js, which is not supported by Angular CLI 8.0+. The official Node.js version that is supported is 10.9 or greater. Please visit https://nodejs.org/en/ to find instructions on how to update Node.js."

Now I want to set the default node version of the docker container in the provision step to VERSION_NODE_10 which is already defined in the container.

# Framework Versions ENV VERSION_NODE_8=8.12.0 ENV VERSION_NODE_6=6 ENV VERSION_NODE_10=10 ENV VERSION_NODE_DEFAULT=$VERSION_NODE_8 <-- Change this to $VERSION_NODE_10 ENV VERSION_RUBY_2_3=2.3.6 ENV VERSION_RUBY_2_4=2.4.3 ENV VERSION_RUBY_DEFAULT=$VERSION_RUBY_2_3 ENV VERSION_HUGO=0.51 ENV VERSION_YARN=1.13.0 

amplify.yml:

version: 0.1 backend:   phases:     build:       commands:         - '# Execute Amplify CLI with the helper script'         - amplifyPush --simple frontend:   phases:     preBuild:       commands:         - npm ci     build:       commands:         - node -v         - npm run-script build   artifacts:     baseDirectory: dist/cr-client     files:       - '**/*'   cache:     paths:       - node_modules/**/*

Does anyone know how to change the default?

like image 804
Slohrsh Avatar asked Jun 04 '19 12:06

Slohrsh


People also ask

How do I switch between node versions?

Switching among Node. 7; we can simply run either nvm use 12.22. 7 or nvm use 16.13. 0 to easily switch into either version we need. Note that since we only have one version that begins with 12, 14, or 16, we can switch versions with a simple nvm use 16 , nvm use 14 , or nvm use 12 command.

What version of node does amplify use?

Amplify CLI replaces Node. js 8.10 with Node. js 10 in the Lambda functions that it creates for you.

How do I change to lower version in NodeJs?

Changing Node.To change Node. JS versions, we have to first download the version we want. Make sure you have nvm installed first. If you don't know the version you want to install, type nvm ls-remote to get a full list of all installable Node.


1 Answers

AWS Amplify use nvm to handle node version. Try this:

version: 0.1 backend:   phases:     build:       commands:         - '# Execute Amplify CLI with the helper script'         - amplifyPush --simple frontend:   phases:     preBuild:       commands:         - nvm use $VERSION_NODE_10         - npm ci     build:       commands:         - nvm use $VERSION_NODE_10         - node -v         - npm run-script build   artifacts:     baseDirectory: dist/cr-client     files:       - '**/*'   cache:     paths:       - node_modules/**/* 
like image 101
richard Avatar answered Oct 13 '22 03:10

richard