NextJS 在 AWS 上的部署放大问题(前端 + 不兼容模块)
NextJS deployment on AWS amplify issue (frontend + incompatible module)
我通过连接github repo部署nextjs项目,配置通过,后端构建,但前端构建失败。这是错误的日志:
# 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...
构建设置:
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
我真的不知道如何解决这个问题,这是 AWS 问题还是我的项目有过时的包?任何帮助将不胜感激。
要解决此问题,您必须告诉 Amplify 使用哪个版本的 NodeJS。
前往:
构建设置
底部是编辑构建图像设置
单击添加包覆盖
设置您的 NodeJS 版本
这对我有用。
我通过连接github repo部署nextjs项目,配置通过,后端构建,但前端构建失败。这是错误的日志:
# 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...
构建设置:
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
我真的不知道如何解决这个问题,这是 AWS 问题还是我的项目有过时的包?任何帮助将不胜感激。
要解决此问题,您必须告诉 Amplify 使用哪个版本的 NodeJS。
前往: 构建设置 底部是编辑构建图像设置 单击添加包覆盖
设置您的 NodeJS 版本
这对我有用。