Open
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
Try to install something on global npm install -g [package]
an error is thrown:
37 verbose stack RangeError: Maximum call stack size exceeded
37 verbose stack at isPathSeparator (node:path:52:25)
37 verbose stack at resolve (node:path:217:13)
37 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\realpath.js:18:10)
37 verbose stack at realpathCached (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\realpath.js:38:10)
I added some logging to realpath.js to see what it was doing...
console.log(depth, dir, path, dir == path, base);
undefined \\SOURCE2\Users\danF\AppData\Roaming \\SOURCE2\Users\danF\AppData\Roaming\npm false npm
NaN \\SOURCE2\Users\danF\AppData \\SOURCE2\Users\danF\AppData\Roaming false Roaming
NaN \\SOURCE2\Users\danF \\SOURCE2\Users\danF\AppData false AppData
NaN \\SOURCE2\Users\ \\SOURCE2\Users\danF false danF
NaN \\SOURCE2\Users\ \\SOURCE2\Users\ true Users
NaN \\SOURCE2\Users\ \\SOURCE2\Users\ true Users
NaN \\SOURCE2\Users\ \\SOURCE2\Users\ true Users
NaN \\SOURCE2\Users\ \\SOURCE2\Users\ true Users
NaN \\SOURCE2\Users\ \\SOURCE2\Users\ true Users
...repeats until stack overflow or whatever
Expected Behavior
Expected bahavior...it works? i guess.
Given this the repeating directory error, I changed line 33 from:
if (!base) {
rpcache.set(dir, dir)
return Promise.resolve(dir)
}
to
if (!base || dir == path) {
rpcache.set(dir, dir)
return Promise.resolve(dir)
}
so that it recognizes that it has ascended as far as it can and reached the effective 'base'.
I'm no node.js/npm master, so i don't claim that this is a good fix but, i can install things globally now.
Steps To Reproduce
Windows 11. local Domain joined to Windows server, using folder redirection.
I'm not sure what other information to provide here. In this environment, all you have to do is try to install something globally and it fails.
Environment
- npm: 10.5.0
- Node.js: 20.11.1
- OS Name: Windows 11
- System Model Name: Dell generic desktop
- npm config:
; "builtin" config from \\SOURCE2\Users\danF\AppData\Roaming\npm\node_modules\npm\npmrc
prefix = "\\\\SOURCE2\\Users\\danF\\AppData\\Roaming\\npm"
; "user" config from C:\Users\danF.LEE\.npmrc
loglevel = "verbose"
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v20.11.1
; npm local prefix = C:\Users\danF.LEE
; npm version = 10.5.0
; cwd = C:\Users\danF.LEE
; HOME = C:\Users\danF.LEE