Moe Assaf
Moe Assaf

Reputation: 13

NextJS deployment on AWS amplify issue (frontend + incompatible module)

I deploy the nextjs project by connecting the github repo, the provision passes, the backend is built, but the frontend fails to build. Here is the log with the error:

                                 # Starting phase: preBuild
                                 # Executing command: yarn install
2021-12-13T06:55:51.568Z [INFO]: yarn install v1.22.0
2021-12-13T06:55:51.620Z [INFO]: [1/4] Resolving packages...
2021-12-13T06:55:51.815Z [INFO]: [2/4] Fetching packages...
2021-12-13T06:56:02.529Z [WARNING]: error [email protected]: The engine "node" is incompatible with this module. Expected version ">=12.22.0". Got "12.21.0"
2021-12-13T06:56:02.537Z [WARNING]: error Found incompatible module.
2021-12-13T06:56:02.538Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
2021-12-13T06:56:02.550Z [ERROR]: !!! Build failed
2021-12-13T06:56:02.552Z [ERROR]: !!! Non-Zero Exit Code detected
2021-12-13T06:56:02.552Z [INFO]: # Starting environment caching...
2021-12-13T06:56:02.552Z [INFO]: # Environment caching completed
Terminating logging...

The build settings:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

I really do not know how to fix this, is it an AWS issue or my project has outdated packages? Any help would be appreciated 😄.

Upvotes: 0

Views: 1814

Answers (1)

To fix this issue you have to tell Amplify which version of NodeJS to use.

Go To: Build Settings At the bottom is Edit Build image settings Click Add Package Overide

Set your NodeJS version

This worked for me.

Upvotes: 1

Related Questions