From 8fd670cf28b6a2009311194a47943e27184f0589 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 23 Dec 2024 14:23:50 +0900 Subject: [PATCH] fix: test error on Node.js v18 and npm v11 (#37) npm v11 has dropped the support for Node.js v18: https://github.com/npm/cli/releases/tag/v11.0.0 So this change installs npm v10 instead on Nodde.js v18. ```sh-session $ npm v npm@11.0.0 engines { node: '^20.17.0 || >=22.9.0' } $ npm v npm@10.9.2 engines { node: '^18.17.0 || >=20.5.0' } ``` --- .github/workflows/nodejs-ci.yml | 2 +- .github/workflows/nodejs-test-reusable.yml | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nodejs-ci.yml b/.github/workflows/nodejs-ci.yml index 5568813..afdde7b 100644 --- a/.github/workflows/nodejs-ci.yml +++ b/.github/workflows/nodejs-ci.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: ["lts/*", "20", "16"] + node-version: ["lts/*", "20", "18", "16"] os: ["ubuntu-latest"] uses: ./.github/workflows/nodejs-test-reusable.yml with: diff --git a/.github/workflows/nodejs-test-reusable.yml b/.github/workflows/nodejs-test-reusable.yml index 2063d33..b678dcb 100644 --- a/.github/workflows/nodejs-test-reusable.yml +++ b/.github/workflows/nodejs-test-reusable.yml @@ -46,13 +46,18 @@ jobs: - name: Update npm to latest shell: bash - # NOTE: npm v10 has dropped support for Node.js v16. run: | - if [[ $(node -v) =~ ^v(16|14|12|10)\. ]]; then - npm install --global npm@9 - else - npm install --global npm@latest - fi + case $(node -v) in + v16.*|v14.*|v12.*|v10.*) + npm install --global npm@9 + ;; + v18.*) + npm install --global npm@10 + ;; + *) + npm install --global npm@latest + ;; + esac echo "Successfully updated npm to $(npm -v)" - name: Install dependencies