Skip to content

Cannot update NPM on Linux runners unless node_version is explicitly set #1409

@dmurvihill

Description

@dmurvihill

Description:
setup-node defaults to the Node version that comes installed on the host. On Linux runners, this is installed with sudo, making it impossible to update NPM (as well as Node itself, I assume). Further, the error message is a message from the OS which is very unhelpful in a GHA context.

This appears to be a known issue since 2021.

Action version:
Specify the action version

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:

workflows/ci.yml

on:
  workflow_dispatch:
jobs:
  release-dry-run:
    permissions:
      id-token: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}
      - uses: ./.github/actions/set-up-ci

set-up-ci/action.yml

name: "Setup"
description: "Set up Node and install project dependencies"
inputs:
  node-version:
    description: Node version to set up
    required: false # Defaults to "node-version-file"
  npm-version:
    description: NPM version to use for the package
    default: 11.5.1

runs:
  using: "composite"
  steps:
    - uses: actions/setup-node@v4
      with:
        node-version: ${{ inputs.node-version }}
        check-latest: true
        cache: "npm"
        cache-dependency-path: "package-lock.json"
    - run: node --version
      shell: "bash"
    - name: install latest npm
      run: npm install -g npm@${{ inputs.npm-version }}
      shell: "bash"
    - name: install dependencies
      run: npm ci
      shell: "bash"

Expected behavior:
Should be able to update NPM.

Actual behavior:
When updating NPM, the action fails:


Run npm install -g npm@11.5.1
  npm install -g npm@11.5.1
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  
npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/share/man/man7
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/local/share/man/man7'
npm error     at async mkdir (node:internal/fs/promises:858:10)
npm error     at async Promise.all (index 0)
npm error     at async Promise.all (index 1)
npm error     at async #createBinLinks (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:394:5)
npm error     at async Promise.allSettled (index 0)
npm error     at async #linkAllBins (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:375:5)
npm error     at async #build (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:160:7)
npm error     at async Arborist.rebuild (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:62:5)
npm error     at async [reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
npm error     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5) {
npm error   errno: -13,
npm error   code: 'EACCES',
npm error   syscall: 'mkdir',
npm error   path: '/usr/local/share/man/man7'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2025-10-14T22_12_14_860Z-debug-0.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions