Why does AWS amplify does not recognize updated node version?

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error Why does AWS amplify does not recognize updated node version? on this date .

I upgraded node on my local machine as well as migrated from create-react-app to nextjs.

When I pushed my code to AWS Amplify, I got this error:

error game-night@0.1.0: The engine "node" is incompatible with this module. Expected version ">=12.22.0". Got "12.21.0"

error Found incompatible module.

info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I’ve looked on stackoveflow and other blogs and I’ve tried everything, but I still get this error.

My trials:

  • Added engines: node to my package.json
"engines": {
    "node": ">=12.22.0"
  }
  • Ran these commands:
sudo npm cache clean -f
sudo npm install -g n
  • Double checked my node version:
node -v                                                                              
v16.13.0
  • Deleted and then installed the node modules folder with yarn install

Why is this error still occurring?

Answer

You are only using node v16 locally, amplify for some reason uses a lower one. You could either downgrade the package (not recommended imho) or tell amplify to use a higher node version (recommended imho).

frontend:
  phases:
    preBuild:
      commands:
        - nvm install 16

Find the official documentation on how to change build settings here:

https://docs.aws.amazon.com/amplify/latest/userguide/build-settings.html