memory-fs icon indicating copy to clipboard operation
memory-fs copied to clipboard

Should recognize and handle UNC path on Windows correctly

Open compulim opened this issue 9 years ago • 1 comments

In pathToArray function, if the path looks like \\SERVER\folder\subfolder\abc.txt, it will throw MemoryFileSystemError(errors.code.EINVAL, path).

This is causing issues with Node.js >= 6.0.0 when bundling with Webpack on a UNC path.

Repro steps:

  1. Mapped \\SERVER\folder to Z:
  2. Setup a webpack.config.js that has an entry based on __dirname

Expected: Webpack should bundle successfully

Actual: Node.js >= 6.0.0: Webpack failed because pathToArray does not recognize UNC path Node.js < 6.0.0: Bundle successfully

This is because under Node.js >= 6.0.0. Any JS modules on a mapped drive Z:, the __dirname will be relative to \\SERVER\folder\, instead of Z:\. And Webpack will fail because memory-fs could not recognize UNC path correctly.

There is currently no workaround as the new behavior on __dirname is consistent across all modules. The only way is to use process.cwd() instead but the solution is limited.

This is a blocking issue for Webpack bundler to run on Azure Web App with Node.js >= 6.0.0.

The correct behavior of pathToArray should be recognizing \\SERVER\folder and turn it into ['\\SERVER', 'folder'].

compulim avatar Aug 30 '16 18:08 compulim

yep, it should handle these paths. PR?

sokra avatar Sep 07 '16 17:09 sokra