Skip to content

[BUG] npm complains not knowing command 'pm' under pwsh7 #8528

@jessehouwing

Description

@jessehouwing

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

This may have been solved in the most recent version, but I can't consistently fic the issue on GitHub Actions Hosted Runners.

When using Node 22.18.0, without updating npm the following is true, and updating npm in the workflow also fails.

When running

& npm install tfx-cli@latest -g

Using Node 22, latest npm, I get the following error message:

& npm install tfx-cli@latest -g

Unknown command: "pm"

To see a list of supported npm commands, run:
  npm help

Removing the & in this case fixes the issue.

npm install tfx-cli@latest -g
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

added 218 packages in 16s 

This issue was recently introduced and started breaking existing scripts.

Similarly & "npm" install will now also fail.

When upgrading npm as part of my GitHub Actions workflow, the behavior stays the same. Locally, when upgrading npm to latest, the issue goes away.

Expected Behavior

& "npm" install
& npm install
npm install

all work without complaining about missing files or unknown commands

Steps To Reproduce

The following GitHub Actions woprkflow shows the problem:

name: Show npm issue

on:
  workflow_dispatch:

jobs:

  update:

    runs-on: windows-latest

    steps:
      - name: Use node 22
        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
        with:
          node-version: 22

      - name: Download recent extensions
        run: |
          & npm install npm@latest -g

https://github.com/renovatebot/azure-devops-marketplace/actions/runs/17211796029/job/48825249286

Even adding an explicit update to latest npm in the workflow fails:

https://github.com/renovatebot/azure-devops-marketplace/actions/runs/17213248909/job/48830235233

Environment

 azure-devops-marketplace  npm -v
10.9.3
 azure-devops-marketplace  node -v
v22.18.0

Windows 11 24h2 x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsplatform:windowsis Windows-specific

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions