[BUG] NPM Scripts with Colons Break w/ Windows File Paths #5093
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
Is there an existing issue for this?
This issue exists in the latest npm version
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:
At other times, this error occurs:
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
tofoo-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...
scripts
section ofpackage.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
npm run foo:bar
[or whatever the name of the script is]a.
filename, directory name, or volume label syntax is incorrect
b.
no such file or directory
Environment
The text was updated successfully, but these errors were encountered: