Windows 写入文件错误
haiweilian opened this issue · comments
HaiWei Lian commented
windows 的路径是 \
分割符,用 path.substring(0, path.lastIndexOf('/'))
拆分目录不兼容。可以使用内置的方法 path.dirname
获取目录,不会有兼容问题。
错误信息
Error: ENOENT: no such file or directory, open 'E:\haiweilian\github\vlib-starter\packages\vlib-ui\dist\tags.json'
at Object.openSync (node:fs:603:3)
at Object.writeFileSync (node:fs:2324:35)
at E:\haiweilian\github\vlib-starter\packages\vlib-ui\scripts\build\task\helper.js:700:8
at FSReqCallback.oncomplete (node:fs:200:23)
at FSReqCallback.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'E:\\haiweilian\\github\\vlib-starter\\packages\\vlib-ui\\dist\\tags.json'
}
Node.js v18.18.0