node.js - 如何在Amplify Console的置备步骤中更改 Node 版本

标签 node.js amazon-web-services aws-amplify

我面临着无法通过AWS Amplify控制台构建Angular应用程序的问题:
“您正在运行Node.js的v8.12.0版本,Angular CLI 8.0+不支持该版本。
支持的官方Node.js版本为10.9或更高版本。
请访问https://nodejs.org/en/以找到有关如何更新Node.js的说明。”
现在,我想在供应步骤中将Docker容器的默认节点版本设置为VERSION_NODE_10,该版本已在容器中定义。

# Framework Versions
ENV VERSION_NODE_8=8.12.0
ENV VERSION_NODE_6=6
ENV VERSION_NODE_10=10
ENV VERSION_NODE_DEFAULT=$VERSION_NODE_8 <-- Change this to $VERSION_NODE_10
ENV VERSION_RUBY_2_3=2.3.6
ENV VERSION_RUBY_2_4=2.4.3
ENV VERSION_RUBY_DEFAULT=$VERSION_RUBY_2_3
ENV VERSION_HUGO=0.51
ENV VERSION_YARN=1.13.0
amplify.yml:

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - node -v
        - npm run-script build
  artifacts:
    baseDirectory: dist/cr-client
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

有谁知道如何更改默认值?

最佳答案

AWS Amplify使用nvm处理节点版本。试试这个:

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - nvm use $VERSION_NODE_10
        - npm ci
    build:
      commands:
        - nvm use $VERSION_NODE_10
        - node -v
        - npm run-script build
  artifacts:
    baseDirectory: dist/cr-client
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

关于node.js - 如何在Amplify Console的置备步骤中更改 Node 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56444337/

相关文章:

node.js - 如何导入没有可用类型的 npm 模块?

xml - NodeJS如何按元素查找所有XML Node

amazon-web-services - 创建 AWS 账户配置的备份

amazon-web-services - 亚马逊 Redshift 中的while循环

amazon-web-services - AWS Amplify - AppSync 和多个 DynamoDB 表

javascript - CORS header 在 MEAN 堆栈应用程序中不起作用

node.js - 启动 sailsJS 项目时更改环境

amazon-web-services - 如何让VPC中的AWS Lambda发布SNS通知?

wordpress - 如何同时有效地设置 wordpress 和 AWS Amplify?

reactjs - AWS-Amplify Authenticator 支持经过身份验证和未经身份验证的页面