npm breaks on Windows when running off a UNC path


(Kafungo Wangure) #1

I have an electron project in a directory at a UNC path: \\myserver\User\me\path\to\project\electron-project.

REPRO STEPS:

  • create a UNC directory, e.g. \\myserver\path\to\project\electron-project.
  • In there, create a package.json with the following contents.{
    “name”: “app”
    , “version”: “0.0.1”
    , “private”: true
    , “dependencies”: {
    “electron”: “^3.0.4”
    }
    }
  • Open a PowerShell window, and cd to \\myserver\path\to\project\electron-project .
  • In there, run the following run npm install

Output:

CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
npm WARN enoent ENOENT: no such file or directory, open 'C:\Windows\package.json'
npm WARN Windows No description
npm WARN Windows No repository field.
npm WARN Windows No README data
npm WARN Windows No license field.

npm ERR! path C:\Windows\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall mkdir
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Windows\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, mkdir 'C:\Windows\node_modules'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, mkdir 'C:\Windows\node_modules'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'mkdir',
npm ERR!      path: 'C:\\Windows\\node_modules' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, mkdir \'C:\\Windows\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Windows\\node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in: \\myserver\User\me\windowsoverhead\appdata\npm-cache\_logs\2018-10-30T14_20_06_361Z-debug.log

Note that this is a previously “solved” bug. The exact same problem can be seen in this github issue, and should have been solved with this commit in 2012. But I’m running npm version 6.4.1 and node v8.12.0 and yet the problem persists.

$ npm -v
'\\myserver\User\me\project'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
6.4.1

Any help would be appreciated!