Description
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
This bug has been reported a number of times before (#3349, #1189) , as far back as v6 as far as I can tell.
I am not sure why, but such bug reports seem to get little to no attention from npm folks, and then eventually someone or some bot just closes the bug and says "too old, please re-open". SMH. So here I am, opening yet again.
I'm on version 9.5.1 of npm, on Windows 11.
I also have WSL2 (Debian) on this machine, which means I have a linux filesystem that windows mounts at a path like:
\\wsl$\Debian\home\my-user\tmp
These paths (I guess called "UNC paths"?) work fine across Windows, in File Explorer and pretty much all windows apps I use (like Sublime, Chrome, etc).
If I go into a Windows shell (i.e., Powershell), and switch to that path, it works fine:
PS C:\Users\my-user> cd \\wsl$\Debian\home\my-user\tmp
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Debian\home\my-user\tmp>
I can the n issue a command like this, and it works fine:
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Debian\home\my-user\tmp> node --version
v19.8.1
However, if I then issue a npm
command from that location, I get an error:
PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Debian\home\my-user\tmp> npm --version
'\\wsl$\Debian\home\my-user\tmp'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
9.5.1
As you can see, the command runs, but not in the correct working directory.
For --version
, that's mildly annoying, but no big deal. But other commands, like npm install
, run in C:\Windows
working directory instead of where I want them to run, which is completely broken and very bad.
Obviously, the command should run in the current working directory I am in.
Expected Behavior
I expect the npm
program to run in whatever working directory I'm in, regardless of how the (valid) path looks, without errors or (worse!) switching to another directory to run the command!
As a bad (but at least reasonable) fallback, if there's just no way UNC paths could be supported (which is terrible), at a minimum these commands should just refuse to run altogether, rather than running in the wrong directory -- especially C:\Windows
... good grief!
Steps To Reproduce
- windows 10 or 11
- with WSL2 installed, with a linux distribution like Ubuntu or Debian, and a file system mounted in windows like
\\wsl$\Debian\home\my-user\tmp
- also with node and npm installed in windows, not just inside of WSL
- open powershell, and do
cd
to switch to that directory location - issue command
npm install
- notice the error about "UNC Paths" not being supported and how the npm command (like for example an
npm install
) operates in the defaultC:\Windows
directory incorrectly
Environment
- npm: 9.5.1
- Node.js: 19.8.1
- OS Name: Windows 11 Professional
- System Model Name: Surface Laptop 5
- npm config:
PS C:\Users\my-user> npm config list -l
; "default" config from default values
_auth = (protected)
access = null
all = false
allow-same-version = false
also = null
audit = true
audit-level = null
auth-type = "web"
before = null
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\my-user\\AppData\\Local\\npm-cache"
cache-max = null
cache-min = 0
cafile = null
call = ""
cert = null
ci-name = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
diff = []
diff-dst-prefix = "b/"
diff-ignore-all-space = false
diff-name-only = false
diff-no-prefix = false
diff-src-prefix = "a/"
diff-text = false
diff-unified = 3
dry-run = false
editor = "C:\\Windows\\notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
force = false
foreground-scripts = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\my-user\\AppData\\Roaming\\npm\\etc\\npmrc"
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
include = []
include-staged = false
include-workspace-root = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\my-user\\.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "C:\\Users\\my-user\\.npm-init.js"
init.version = "1.0.0"
install-links = false
install-strategy = "hoisted"
json = false
key = null
legacy-bundling = false
legacy-peer-deps = false
link = false
local-address = null
location = "user"
lockfile-version = null
loglevel = "notice"
logs-dir = null
logs-max = 10
; long = false ; overridden by cli
maxsockets = 15
message = "%s"
metrics-registry = "https://registry.npmjs.org/"
node-options = null
noproxy = [""]
offline = false
omit = []
omit-lockfile-registry-resolved = false
only = null
optional = null
otp = null
pack-destination = "."
package = []
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" ; overridden by builtin
preid = ""
production = null
progress = true
provenance = false
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
replace-registry-host = "npmjs"
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-peer = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
searchexclude = ""
searchlimit = 20
searchopts = ""
searchstaleness = 900
shell = "C:\\Windows\\system32\\cmd.exe"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
strict-peer-deps = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "C:\\Users\\my-user\\AppData\\Local\\Temp"
umask = 0
unicode = false
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "C:\\Users\\my-user\\.npmrc"
version = false
versions = false
viewer = "browser"
which = null
workspace = []
workspaces = null
workspaces-update = true
yes = null
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\my-user\\AppData\\Roaming\\npm"
; "cli" config from command line options
long = true