Issue 1:
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

When running an npm script with a colon (:) in its name, Windows will return a number of different errors.

Sometimes the error is as follows:

The filename, directory name, or volume label syntax is incorrect.

At other times, this error occurs:

Error: ENOENT: no such file or directory, open 'C:\Users\Chris\AppData\Local\Temp\foo:bar-1656368147831.cmd'
at Object.openSync (node:fs:585:3)
at writeFileSync (node:fs:2170:35)
at makeSpawnArgs (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\make-spawn-args.js:82:3)
at runScriptPkg (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script-pkg.js:57:55)
at runScript (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script.js:9:16)
at RunScript.run (C:\Program Files\nodejs\node_modules\npm\lib\commands\run-script.js:125:13)
at async module.exports (C:\Program Files\nodejs\node_modules\npm\lib\cli.js:78:5)

I haven't been able to nail down exactly what causes the differing behavior, sometimes they will alternate when I run the same command, in the same terminal session, one right after the other.

Interestingly, when I highlight the name of the "missing" file in the VS Code integrated terminal, only the path up to the first colon is highlighted as being a navigable path.

Expected Behavior

When I use npm run foo:bar, I'd like it to successfully execute the script of the same name.

When I roll back to npm 8.11.0 using nvm, I get the irritating config global '--global', '--local' are deprecated. Use '--location=global' instead. error, but I am able to successfully execute scripts with colons in their names.

Workaround

I'm extremely confident that this issue between npm and the Windows filesystem is caused by the colons, because when I change the name of the script by replacing the colons with hyphens (foo:bar to foo-bar), the script works perfectly.

When I mentioned this problem to my coworkers, they said that they were able to use scripts w/ colon names without issue. I had updated my npm that morning, but they were still using npm version 8.11, so this error is definitely caused by something that was changed in the last few versions.

I don't yet know whether npm 8.12 has similar problems.

Steps To Reproduce

In a Windows 10 environment...

Install or update to npm 8.13.1

Initialize or navigate to a node.js project

Within the scripts section of package.json:

a. Create a script with a colon in its name (ex. foo:bar)

b. The actual contents of the script don't matter, just the name

From a command prompt or Powershell terminal, execute npm run foo:bar [or whatever the name of the script is]

Observe one of the above mentioned errors, either

a. filename, directory name, or volume label syntax is incorrect

b. no such file or directory

Environment

npm: 8.13.1

Node.js: v16.15.1

OS Name: Windows 10 21H2 (Build 19044.1766)

System Model Name: Dell Precision 5550

npm config:

; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\\Users\\Chris\\AppData\\Roaming\\npm"

; "global" config from C:\Users\Chris\AppData\Roaming\npm\etc\npmrc

include = ["dev"]
omit = []

; "user" config from C:\Users\Chris\.npmrc

strict-ssl = false

; "project" config from C:\Users\Chris\development\spotify-playlist-maker\.npmrc

always-auth = true
registry = "https://registry.npmjs.org/"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.15.1
; npm local prefix = C:\Users\Chris\development\spotify-playlist-maker
; npm version = 8.13.1
; cwd = C:\Users\Chris\development\spotify-playlist-maker
; HOME = C:\Users\Chris
; Run `npm config ls -l` to show all defaults.

Issue 2:
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

I am unable to run scripts defined in my package.json. npm run <script> outputs The filename, directory name, or volume label syntax is incorrect. (translated from german 'Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.')

Downgrading to v8.12.2 for now as scripts are able to run using this npm version.

Expected Behavior

All scripts should run without an error.

Steps To Reproduce

Install the latest npm version 8.13.0 globally

Run any script defined in your package.json

See error: The filename, directory name, or volume label syntax is incorrect. (translated from german 'Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.')

Environment

npm: 8.13.0

Node.js: 16.15.1

OS Name: Windows 10

System Model Name: HP ZBook

npm config:

; "builtin" config from C:\Users\[retracted]\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\[retracted]\\AppData\\Roaming\\npm"

; "user" config from C:\Users\[retracted]\.npmrc

[retracted]:registry = "[retracted]"
[retracted]:registry = "[retracted]"
[retracted]
registry = "[retracted]"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.15.1
; npm local prefix = [retracted]
; npm version = 8.13.0
; cwd = [retracted]
; HOME = C:\Users\[retracted]
; Run `npm config ls -l` to show all defaults.