提供了我的CircleCI文件:
version: 2.1
orbs:
node: circleci/node@4.1.0
aws-cli: circleci/aws-cli@2.0.3
eb: circleci/aws-elastic-beanstalk@2.0.1
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安装v16.9.0
的节点版本,我需要使用v12
。因此,我运行额外的命令来使用NVM使用v12。
是否有更简单的方法在安装期间使用特定版本的Node ?
使用带有节点版本的cim作为docker映像应该可以工作。你不需要使用nvm手动安装。
jobs:
build:
docker:
- image: cimg/node:12.16
https://hub.docker.com/r/cimg/node
我用的是cimg/node:16.13.2
,它工作得很好。
我认为问题是orbs
,因为在我更新到node: circleci/node@4.7.0
之后,我没有NodeJS安装和构建项目的问题。
这是有意义的,因为cI/CD管道不应该运行软件,因此,NodeJS版本应该是不相关的。