Skip to content

Unable to set global npm version, npm v8 is always used... #376

Closed
@busticated

Description

@busticated

Description:
I need to run my action using npm@6. Despite installing the correct version globablly, npm@8 is always used and my action fails. i see a series of warnings in my logs like:

my-package: npm WARN EBADENGINE Unsupported engine {
my-package: npm WARN EBADENGINE   package: '@particle/tmp@2.0.1',
my-package: npm WARN EBADENGINE   required: { node: '>=10', npm: '6.x' },
my-package: npm WARN EBADENGINE   current: { node: '12.22.7', npm: '8.1.0' }
my-package: npm WARN EBADENGINE }

i first noticed the failure on monday (12/6/2021), the last successful run was ~7days ago (11/30/2021 - log)

inspecting the logs for both runs, i see Current runner version: '2.284.0' (success) vs. Current runner version: '2.285.1' (fail). looks like the earliest failure happened under Current runner version: '2.285.0' which was released ~8days ago (info)

running locally (outside of GH Actions entirely but within a comparable environment), i'm able to reproduce the warnings and subsequent failures by simply using npm@8. at no point does my code attempt to install npm@8. reverting to npm@6 and re-running fixes things.

the Unsupported engine warnings are triggered by running a tool which itself runs npm via child-process in a descendant directory (see here). this is what my npm run build command does under the hood.

interestingly, Node.js v12.22.7 ships w/ npm@6.14.15 by default (see ~pg10 here) so something is explicitly pulling in npm@8.1.0 somewhere

Action version:
v2.5.0, v2.4.1, and v2.4.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:
node: v12.22.7
npm: 6.14.15 (but npm@8.1.0 is always used)

Repro steps:
Using an action step like:

      - uses: actions/setup-node@v2
        with:
          node-version: '12'
          registry-url: 'https://registry.npmjs.org'
      - name: Install Dependencies
        run: |
          npm ci
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
      - name: Debug
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
        run: |
          echo ":::: NPM SETTINGS"
          npm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
          node --version
          npm --version
          npm whoami
          npm i npm@6 --global
          npm run build

(note: using either ubuntu-18.04 or ubuntu-latest yields the same result)

Expected behavior:

npm run build command succeeds, npm@6 is used

Actual behavior:

npm run build fails with the following log output:

my-package: npm WARN EBADENGINE Unsupported engine {
my-package: npm WARN EBADENGINE   package: '@particle/tmp@2.0.1',
my-package: npm WARN EBADENGINE   required: { node: '>=10', npm: '6.x' },
my-package: npm WARN EBADENGINE   current: { node: '12.22.7', npm: '8.1.0' }
my-package: npm WARN EBADENGINE }

npm@8 is used despite previously installing npm@6 via npm i npm@6 --global and despite Node.js v12.22.7 shipping with npm@6.14.15 by default

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