Skip to content

[BUG] the different output of run npm run command #6411

Open
@simo-an

Description

@simo-an

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

the scripts in package is

  "scripts": {
    "test": "node index.js --PROJECT_ROOT $(pwd)"
  },

the index.js file content is

console.warn(process.argv)

i run two command in git bash of win10 os

  1. npm run test
    output
$ npm test

> test-command@1.0.0 test
> node index.js --PROJECT_ROOT $(pwd)

[
  'C:\\Program Files\\nodejs\\node.exe',
  'D:\\Test\\test-command\\index.js',
  '--PROJECT_ROOT',
  '$(pwd)'
]
  1. node index.js --PROJECT_ROOT $(pwd)
    output
$ node index.js --PROJECT_ROOT $(pwd)
[
  'C:\\Program Files\\nodejs\\node.exe',
  'D:\\Test\\test-command\\index.js',
  '--PROJECT_ROOT',
  'D:/Test/test-command'
]

Expected Behavior

two command output same result as last one

Steps To Reproduce

  1. create test project

index.js

console.warn(process.argv)

package.json

{
  "name": "test-command",
  "version": "1.0.0",
  "main": "index.js",
  "author": "June",
  "scripts": {
    "test": "node index.js --PROJECT_ROOT $(pwd)"
  }
}

  1. run command

run npm run test
run node index.js --PROJECT_ROOT $(pwd)

you will see the different result

Environment

  • npm: 9.6.5
  • Node.js: v16.14.2
  • OS Name: win10
  • System Model Name: dell xps 15
  • npm config:
$ npm config ls
; "user" config from C:\Users\june\.npmrc

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.14.2
; npm local prefix = D:\Test\test-gitcommand
; npm version = 9.6.5
; cwd = D:\Test\test-command
; HOME = C:\Users\june
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 9.xwork is associated with a specific npm 9 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions