Could not dynamically require "@libsql/win32-x64-msvc"

Full error:
Error: Could not dynamically require "@libsql/win32-x64-msvc". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
at commonjsRequire (C:\Repos\poker-game-manager\.vite\build\main.js:29500:9)
...
Error: Could not dynamically require "@libsql/win32-x64-msvc". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
at commonjsRequire (C:\Repos\poker-game-manager\.vite\build\main.js:29500:9)
...
` Using libsql for an electron application (electron forge, vite) I got this error. Same for better_sqlite3 but it was about not being able to dynamically require that package. I've tried doing as it said and of course asking various AIs and neither:
import path from "node:path";
import { defineConfig } from "vite";

// https://vitejs.dev/config
export default defineConfig({
resolve: {
alias: {
"@shared": path.resolve(__dirname, "src/shared"),
"@main": path.resolve(__dirname, "src/main"),
},
},
build: {
commonjsOptions: {
dynamicRequireTargets: ["@libsql/win32-x64-msvc"],
},
// rollupOptions: {
// external: ["@libsql/client", "@libsql/win32-x64-msvc"],
// },
},
});
import path from "node:path";
import { defineConfig } from "vite";

// https://vitejs.dev/config
export default defineConfig({
resolve: {
alias: {
"@shared": path.resolve(__dirname, "src/shared"),
"@main": path.resolve(__dirname, "src/main"),
},
},
build: {
commonjsOptions: {
dynamicRequireTargets: ["@libsql/win32-x64-msvc"],
},
// rollupOptions: {
// external: ["@libsql/client", "@libsql/win32-x64-msvc"],
// },
},
});
or the uncommented version helped. The full version only worked in dev, once built the installer failed with "cannot find module @libsql/client". There was a thread on ansqersoverflow but it was not at all clear to me what they did to get it working exactly nor if it worked when built too. https://www.answeroverflow.com/m/1362542871869395115
Drizzle alongside Electron, Vite and Nuxt - Drizzle Team
Hey! Recently decided to go for Drizzle on my Manga reading app I'm making with electron and nuxtjs (vue framework). However when I compile my code through vite, nuxt-electron and vite-plugin-electron, I get this fatal error: (other message since discord's limit..) It ain't the first time it happened to someone: https://stackoverflow.com/questi...
1 Reply
Father Christmas
Father ChristmasOP5mo ago
The crazy thing is - any combination - even removing the client thing results in the msvg error in dev and any combination results in the client error in prod...

Did you find this page helpful?