问题描述
如果我将我的 webpack 配置的 output.path
属性设置为像 \\COmpuTER-NAME\some-share
这样的 UNC 路径,我会收到以下错误,因为 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 方法 if 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 路径?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)