node.js - CircleCI:使用nodejs版本12

标签 node.js circleci nvm

提供了我的 CircleCI 文件:

version: 2.1
orbs:
  node: circleci/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e70717a7b5e2a302f302e" rel="noreferrer noopener nofollow">[email protected]</a>
  aws-cli: circleci/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f5e484c125c53567f0d110f110c" rel="noreferrer noopener nofollow">[email protected]</a>
  eb: circleci/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="244553570941484557504d47094641454a575045484f64160a140a15" rel="noreferrer noopener nofollow">[email protected]</a>
jobs:
  build:
    docker:
      - image: "cimg/base:stable"
    steps:
      - node/install
      - checkout
      - aws-cli/setup
      - eb/setup
      - run:
          name: Check current version of node
          command: node -v
      - run:
          name: Get and install node version manager.
          command: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
      - run:
          name: Install Node version 12 using NVM
          command: nvm install 12 
      - run:
          name: Use Node version 12 
          command: nvm use 12     
      - run:
          name: Back-End Install
          command: |
            npm run backend:install
      - run:
          name: Front-End Install
          command: |
            npm run frontend:install
      - run:
          name: Back-End Build
          command: |
            npm run backend:build
      - run:
          name: Front-End Build
          command: |
            npm run frontend:build
      - run:
          name: Back-End Deploy
          command: |
            npm run backend:deploy
      - run:
          name: Front-End Deploy
          command: |
            npm run frontend:deploy

在设置过程中,CircleCI 安装 Node 版本为 v16.9.0,我需要使用 v12。因此,我运行额外的命令来使用 NVM 使用 v12。

在设置过程中是否有更简单的方法来使用特定版本的 Node ?

最佳答案

使用带有 Node 版本的 cimg 作为 docker 镜像应该可以工作。您不必使用 nvm 手动安装。

jobs:
  build:
    docker:
      - image: cimg/node:12.16

https://hub.docker.com/r/cimg/node

我正在使用 cimg/node:16.13.2 并且工作正常。

关于node.js - CircleCI:使用nodejs版本12,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69087538/

相关文章:

javascript - 您如何使用 NVM 处理多个 Node 版本和多个项目?

node.js - 我如何获得完整的网址

javascript - Node.js npm 启动错误

AWS ECS 中的 Python 应用程序。如何链接到外部应用程序配置?

linux - 在 Windows 10 上的 ubuntu 上的 bash 上安装 nvm 会抛出错误

node.js - 当我已经在 Ubuntu 上安装了 nodejs 8 时,是否可以安装 NVM?

javascript - 如何在 node.js 沙箱中安全地运行用户提交的脚本?

node.js - 快速 REST API key 身份验证

typescript - CircleCI Angular5 构建失败,因为缺少 firebase secret

git - 如何使用个人访问 token 从 CircleCI 构建推送到 Github 的提交