Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NPM Scripts with Colons Break w/ Windows File Paths #5093

Closed
2 tasks done
chrstophr-wltrs opened this issue Jun 28, 2022 · 3 comments
Closed
2 tasks done

[BUG] NPM Scripts with Colons Break w/ Windows File Paths #5093

chrstophr-wltrs opened this issue Jun 28, 2022 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@chrstophr-wltrs
Copy link

chrstophr-wltrs commented Jun 28, 2022

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...

  1. Install or update to npm 8.13.1
  2. Initialize or navigate to a node.js project
  3. 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
  4. From a command prompt or Powershell terminal, execute npm run foo:bar [or whatever the name of the script is]
  5. 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.
@chrstophr-wltrs chrstophr-wltrs added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jun 28, 2022
@chrstophr-wltrs
Copy link
Author

I know that this is a fairly minor issue. While the colon separators for script titles have been a convention in my workplace for a while, it wouldn't be that difficult to convince them to switch it up, or to simply use a version of node with a working npm. I just figured I should document this as it occurred.

@fritzy
Copy link
Contributor

fritzy commented Jun 28, 2022

Duplicate of #5066
Should be fixed in tomorrow's release.

@fritzy fritzy closed this as completed Jun 28, 2022
@chrstophr-wltrs
Copy link
Author

Duplicate of #5066 Should be fixed in tomorrow's release.

Oh! Sorry I didn't catch that other issue in my search, guess I was being too specific.

Thanks for keeping on top of things. You rock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants