简体   繁体   English

AWS放大问题上的NextJS部署(前端+不兼容的模块)

[英]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.我通过连接github repo来部署nextjs项目,provision通过,后端构建,但是前端构建失败。 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 next@12.0.7: 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?我真的不知道如何解决这个问题,是 AWS 问题还是我的项目有过时的包? Any help would be appreciated.任何帮助,将不胜感激。

To fix this issue you have to tell Amplify which version of NodeJS to use.要解决此问题,您必须告诉 Amplify 使用哪个版本的 NodeJS。

Go To: Build Settings At the bottom is Edit Build image settings Click Add Package Overide Go To: Build Settings 底部是 Edit Build image settings 点击 Add Package Overide

Set your NodeJS version设置你的 NodeJS 版本

This worked for me.这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM