Skip to content
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

Use native better-sqlite3 Error #3

Closed
chenyuyu118 opened this issue Aug 8, 2023 · 5 comments
Closed

Use native better-sqlite3 Error #3

chenyuyu118 opened this issue Aug 8, 2023 · 5 comments

Comments

@chenyuyu118
Copy link

I follow the example of serialport.

{
          entry: "electron/worker.ts",
          onstart(option) {
            option.reload()
          },
          vite: {
            build: {
              rollupOptions: {
                external: ['sqlite3', "better-sqlite3"]
              },
            },
            plugins: [
                native({
                  outDir: 'dist-electron',
                })
            ]
          }
        }

but error occurs like bellow:

node:fs:1396
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, mkdir '/Auto-Defect-Detect/defect-detect/D:/Auto-Defect-Detect/defect-detect/dist-electron'
    at Object.mkdirSync (node:fs:1396:3)
    at configResolved (D:\Auto-Defect-Detect\defect-detect\node_modules\.store\vite-plugin-native@0.2.0\node_modules\vite-plugin-native\dist\index.js:143:12)
    at file:///D:/Auto-Defect-Detect/defect-detect/node_modules/.store/vite@4.4.9/node_modules/vite/dist/node/chunks/dep-df561101.js:65946:28
    at Array.map (<anonymous>)
    at resolveConfig (file:///D:/Auto-Defect-Detect/defect-detect/node_modules/.store/vite@4.4.9/node_modules/vite/dist/node/chunks/dep-df561101.js:65946:14)
    at async Module.build (file:///D:/Auto-Defect-Detect/defect-detect/node_modules/.store/vite@4.4.9/node_modules/vite/dist/node/chunks/dep-df561101.js:47852:20) {
  errno: -4058,
  syscall: 'mkdir',
  code: 'ENOENT',
  path: '/Auto-Defect-Detect/defect-detect/D:/Auto-Defect-Detect/defect-detect/dist-electron'
}
@yejimeiming
Copy link
Member

Can you try use a absolute path other than relative path.

@chenyuyu118
Copy link
Author

chenyuyu118 commented Aug 9, 2023

Can you try use a absolute path other than relative path.

I have tried.But the result output path always have a relative project path whatever the outdir i set.😰

@yejimeiming
Copy link
Member

Okay! I'll try resolve it in the week end :)

@caoxiemeihao
Copy link
Contributor

Maybe you can try the following two cased, the way better-sqlite3 loads .node files is not recognized by the bundler(Vite, Rollup, Webpack) friendly,

https://github.com/caoxiemeihao/electron-vite-samples/tree/main/better-sqlite3-renderer-process
https://github.com/caoxiemeihao/electron-vite-samples/tree/main/better-sqlite3-main-process

@caoxiemeihao
Copy link
Contributor

v2.0.0 is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants