Search code examples
node.jsamazon-web-servicesnext.jsaws-amplify

Why does AWS amplify does not recognize updated node version?


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 [email protected]: 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?


Solution

  • 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