提供了我的 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/