如果我将output.path
webpack 配置的属性设置为 UNC 路径,就像\\COMPUTER-NAME\some-share
我从 webpack 5 开始得到以下错误(它曾经在 webpack 4 中工作):
C:\Temp\dbp\node_modules\webpack\lib\util\fs.js:121
throw new Error(
^
Error: \\COMPUTER-NAME\some-share is neither a posix nor a windows path, and there is no 'join' method defined in the file system
at join (C:\Temp\dbp\node_modules\webpack\lib\util\fs.js:121:9)
at C:\Temp\dbp\node_modules\webpack\lib\Compiler.js:790:31
at arrayIterator (C:\Temp\dbp\node_modules\neo-async\async.js:3467:9)
at timesSync (C:\Temp\dbp\node_modules\neo-async\async.js:2297:7)
at Object.eachLimit (C:\Temp\dbp\node_modules\neo-async\async.js:3463:5)
at emitFiles (C:\Temp\dbp\node_modules\webpack\lib\Compiler.js:536:13)
at C:\Temp\dbp\node_modules\webpack\lib\util\fs.js:182:5
at FSReqCallback.oncomplete (fs.js:171:23)
我查看了 join 方法,如果node_modules\webpack\lib\util\fs.js:121:9
它看起来像:
/**
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
* @param {string} rootPath a path
* @param {string} filename a filename
* @returns {string} the joined path
*/
const join = (fs, rootPath, filename) => {
if (fs && fs.join) {
return fs.join(rootPath, filename);
} else if (rootPath.startsWith("/")) {
return path.posix.join(rootPath, filename);
} else if (rootPath.length > 1 && rootPath[1] === ":") {
return path.win32.join(rootPath, filename);
} else {
throw new Error(
`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`
);
}
};
从我在这里可以看出,如果输入 fs 没有连接方法,则 UNC 路径将不起作用。
我不确定输入 fs 参数是什么。我在 Windows 系统上测试这个,我猜这个功能不存在......
应该支持 UNC 路径吗?