【问题标题】:CircleCI: Use nodejs version 12CircleCI:使用 nodejs 版本 12
【发布时间】:2021-09-07 11:35:48
【问题描述】:

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

在设置期间是否有更简单的方法来使用特定版本的节点?

【问题讨论】:

  • 什么是节点版本?你能试试nvm list 显示本地安装的版本吗@Arefe
  • 我想在 CircleCI 中使用 nodejs 版本 12。请参阅config.yml 文件
  • @Batuhan 我认为问题出在球体上

标签: node.js circleci nvm


【解决方案1】:

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

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

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

我正在使用cimg/node:16.13.2,它工作正常。

【讨论】:

    【解决方案2】:

    我认为问题出在 orbs 上,因为在我更新到 node: circleci/node@4.7.0 后,我在安装 NodeJS 和构建项目方面没有任何问题。

    这是有道理的,因为 cI/CD 管道不应该运行软件,因此 NodeJS 版本应该是无关紧要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-02
      • 2020-09-16
      • 2020-10-25
      • 1970-01-01
      • 1970-01-01
      • 2020-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多