![](/img/trans.png)
[英]@twilio/voice-sdk@2.1.1: The engine "node" is incompatible with this module. Expected version ">= 12". Got "10.19.0"
[英][AWS CodeBuild]The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.19.0"
我正在尝试通过 AWS codepipeline 和 codebuild 部署我的 React 应用程序。
但是,codebuild 失败并出现以下错误:
[Container] 2022/04/19 02:42:19 Waiting for agent ping
[Container] 2022/04/19 02:42:29 Waiting for DOWNLOAD_SOURCE
[Container] 2022/04/19 02:42:30 Phase is DOWNLOAD_SOURCE
[Container] 2022/04/19 02:42:30 CODEBUILD_SRC_DIR=/codebuild/output/src234015054/src
[Container] 2022/04/19 02:42:30 YAML location is /codebuild/output/src234015054/src/buildspec.yml
[Container] 2022/04/19 02:42:30 Processing environment variables
[Container] 2022/04/19 02:42:30 [WARN] Skipping install of runtimes. Runtime version selection is not supported by this build image.
[Container] 2022/04/19 02:42:33 Moving to directory /codebuild/output/src234015054/src
[Container] 2022/04/19 02:42:33 Expanded cache path ./node_modules/**/*
[Container] 2022/04/19 02:42:33 Configuring ssm agent with target id: codebuild:0a77403f-035c-4d62-b96e-de5449f7f4bc
[Container] 2022/04/19 02:42:33 Successfully updated ssm agent configuration
[Container] 2022/04/19 02:42:33 Registering with agent
[Container] 2022/04/19 02:42:33 Phases found in YAML: 2
[Container] 2022/04/19 02:42:33 INSTALL: 2 commands
[Container] 2022/04/19 02:42:33 BUILD: 1 commands
[Container] 2022/04/19 02:42:33 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2022/04/19 02:42:33 Phase context status code: Message:
[Container] 2022/04/19 02:42:33 Entering phase INSTALL
[Container] 2022/04/19 02:42:33 Running command echo Performing yarn install
Performing yarn install
[Container] 2022/04/19 02:42:33 Running command yarn install
yarn install v1.22.4
[1/5] Validating package.json...
error website@0.1.0: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.19.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
我不知道为什么10.19.0
在这里选择了10.19.0。
我正在使用yarn build
来构建 package。我可以在本地使用yarn start
毫无问题地运行该应用程序。
这是我的 buildspec.yml:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
commands:
- echo Performing yarn install
- yarn install
build:
commands:
- yarn build
artifacts:
base-directory: ./build
files:
- "**/*"
cache:
paths:
- "./node_modules/**/*"
我还在package.json
中指定了节点版本:
"name": "my-package",
"version": "0.1.0",
"private": true,
"engines": {
"node": ">=14.0.0",
"npm": ">=8.5.5"
},
我能够根据 fedonev@ 的回答解决问题。
正如他所说,我需要配置构建映像以在 CodeBuild 项目中使用CodeBuild.LinuxBuildImage.STANDARD_5_0
。
// AWS CodePipeline stage to build website
pipeline.addStage({
stageName: "Build",
actions: [
// AWS CodePipeline action to run CodeBuild project
new codepipeline_actions.CodeBuildAction({
actionName: "BuildeWebsite",
project: new CodeBuild.PipelineProject(this, "BuildWebsite", {
projectName: "BuildeWebsite",
environment: {
buildImage: CodeBuild.LinuxBuildImage.STANDARD_5_0
},
buildSpec:
CodeBuild.BuildSpec.fromSourceFilename("./buildspec.yml"),
}),
input: outputSources,
outputs: [outputWebsite],
}),
],
});
您还必须配置 CodeBuild 项目以使用支持 Nodejs v14 运行时的构建映像。 Ubuntu Standard 5 图像是目前唯一可用的图像。 在 CloudFormation 中:
Type: AWS::CodeBuild::Project
Properties:
Environment:
Image: "aws/codebuild/standard:5.0"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.