Skip to content

[BUG] & npm @("run", "ci") in Powershell failed with EUNKNOWNCOMMAND #8176

@adriangodong

Description

@adriangodong

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

Execute the following Powershell command:

& npm @("run", "ci")

This works in Node 20 LTS / npm 10.1.0. In Node 22 LTS / npm 10.9.2, the following error is shown:

Unknown command: "run ci"

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

It seems that npm failed to parse the space and passes "run ci" to cmd-list.js deref. Workaround using & npm.cmd @("run", "ci") is also an option, so this could be an issue with npm.ps1?

Expected Behavior

The command should work as before (npm 10.1.0)

Steps To Reproduce

  1. Node 22 LTS / npm 10.9.1
  2. Run & npm @("run", "ci") in Powershell
  3. Got unknown command error

Environment

  • npm: 10.9.2
  • Node.js: v22.14.0
  • OS Name: Windows 11
  • npm config:
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\\Users\\Adrian Godong\\AppData\\Roaming\\npm"

; "user" config from C:\Users\Adrian Godong\.npmrc

cache = "C:\\Users\\Adrian~1\\AppData\\Roaming\\npm-cache"

; "project" config from C:\Users\Adrian Godong\Desktop\pancore\develop\.npmrc

install-links = false
legacy-peer-deps = true
registry = "**redacted**"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.14.0
; npm local prefix = C:\Users\Adrian Godong\Desktop\**redacted**
; npm version = 10.9.2
; cwd = C:\Users\Adrian Godong\Desktop\**redacted**
; HOME = C:\Users\Adrian Godong
; Run `npm config ls -l` to show all defaults.

Activity

milaninfy

milaninfy commented on Mar 28, 2025

@milaninfy
Contributor

This is working as expected on my end on the latest npm@11.2.0. Also you can run npm ci for clean install.
For your use case could you please share the full logs and complete powershell output ?

adriangodong

adriangodong commented on Mar 28, 2025

@adriangodong
Author

This is working as expected on my end on the latest npm@11.2.0.

Can also repro the issue on npm 11.2.0.

Also you can run npm ci for clean install.

I have a custom script called ci. Same issue with other commands below.

For your use case could you please share the full logs and complete powershell output ?

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.3624
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.3624
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS > npm -v
11.2.0

PS > & npm @("help", "access")
Unknown command: "help access"

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

I'm not sure how to get the full logs.

milaninfy

milaninfy commented on May 7, 2025

@milaninfy
Contributor

You can try updating your powershell, or there might be some powershell related settings/config you can tweak
here is my output

PS C:\Users\Milan> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.4391
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.4391
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\Users\Milan> &npm @("outdated", "-g")
Package   Current  Wanted  Latest  Location               Depended by
corepack   0.31.0  0.32.0  0.32.0  node_modules/corepack  global
npm        10.9.2  11.3.0  11.3.0  node_modules/npm       global


PS D:\test> &npm @("run", "ci")

> test@1.0.0 ci
> echo 'running ci'

running ci
PS D:\test> &npm @("run", "test-script")

> test@1.0.0 test-script
> echo test-script

test-script
PS D:\test> cat .\package.json
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "ci": "echo 'running ci'",
    "test-script": "echo test-script"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "type": "commonjs",
  "dependencies": {
    "lodash": "^4.17.21"
  }
}
PS D:\test>
milaninfy

milaninfy commented on May 9, 2025

@milaninfy
Contributor

Closing this as it's not reproducible as shown in the output. If you are doing things differently or have found any other way to reproduce this issue, feel free to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @adriangodong@milaninfy

        Issue actions

          [BUG] `& npm @("run", "ci")` in Powershell failed with EUNKNOWNCOMMAND · Issue #8176 · npm/cli