路径分隔符不一致,导致windows下不能开发

最近想要基于YAPI扩展开发一个自己的API管理平台,但是发现在windows下直接跑会报错,在Mac跑就没事

报的错是:

Uncaught TypeError: $export is not a function

google了一下,遇到这种问题的解决方法,就是webpack loader上都加上:

exclude: /node_modules/

找了半天,终于发现了webpack配置里面有这个 (注意标红的地方):

exclude: /(tui-editor|node_modules\/(?!_?(yapi-plugin|json-schema-editor-visual)))/

解决方案:

显然,在windows下想要认识这个路径,应该改成这样:

exclude: /(tui-editor|node_modules\\(?!_?(yapi-plugin|json-schema-editor-visual)))/

基础知识:

路径分隔符 在Windows 和 Linux 不相同,
linux文件路径分隔符为 "/" ,windows的文件路径分隔符为 "\"

path.join('foo', 'bar');
// 在 OSX 和 Linux 得到 'foo/bar'
// 在 Windows 得到 'foo\\bar'

猜你喜欢

转载自www.cnblogs.com/amiezhang/p/10460325.html
今日推荐