-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows下better-sqlite3-main-process报错 ENOENT: no such file or directory #10
Comments
我本地做了一些修改解决了该问题😀 - const resolvedRoot = normalizePath(config.root ? path.resolve(config.root) : process.cwd())
- const output = path.posix.resolve(resolvedRoot, options.output)
+ const path$1 = process.platform == 'win32' ? path.win32 : path.posix
+ const resolvedRoot = config.root ? path$1.resolve(config.root) : process.cwd()
+ const output = path$1.resolve(resolvedRoot, options.output)
const better_sqlite3 = require.resolve('better-sqlite3')
- const better_sqlite3_root = path.posix.join(better_sqlite3.slice(0, better_sqlite3.lastIndexOf('node_modules')), 'node_modules/better-sqlite3')
- const better_sqlite3_node = path.posix.join(better_sqlite3_root, 'build/Release', options.better_sqlite3_node)
- const better_sqlite3_copy = path.posix.join(output, options.better_sqlite3_node)
+ const better_sqlite3_root = path$1.join(better_sqlite3.slice(0, better_sqlite3.lastIndexOf('node_modules')), 'node_modules/better-sqlite3')
+ const better_sqlite3_node = path$1.join(better_sqlite3_root, 'build/Release', options.better_sqlite3_node)
+ const better_sqlite3_copy = path$1.join(output, options.better_sqlite3_node)
if (!fs.existsSync(better_sqlite3_node)) {
throw new Error(`${TAG} Can not found "${better_sqlite3_node}".`)
}
@@ -59,7 +59,7 @@ function bindingSqlite3(options: {
}
fs.copyFileSync(better_sqlite3_node, better_sqlite3_copy)
/** `dist-native/better_sqlite3.node` */
- const BETTER_SQLITE3_BINDING = better_sqlite3_copy.replace(resolvedRoot + '/', '')
+ const BETTER_SQLITE3_BINDING = better_sqlite3_copy.replace(resolvedRoot + path.sep, '') |
👍 |
谢谢 解决了我的问题 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我使用的Windows电脑,在better-sqlite3-main-process/下运行示例时,会报ENOENT错误
查询发现是vite.config.ts文件中自定义插件vite-plugin-binding-sqlite3中的路径有一些问题。
vite导出的normalizePath方法处理window下绝对路径后,再通过path.posix.xxx方法处理仍然不兼容。
The text was updated successfully, but these errors were encountered: