WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.22k stars 390 forks source link

vscode extension use better-sqlite3 error #1194

Closed belief-cyf closed 3 weeks ago

belief-cyf commented 1 month ago

I am developing a vscode extension。 import Database from 'better-sqlite3' then move node_modules/better-sqlite3/build to vscode/build error log: rejected promise not handled within 1 second: Error: The module '/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/build/Release/better_sqlite3.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 115. This version of Node.js requires NODE_MODULE_VERSION 119. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). extensionHostProcess.js:147 stack trace: Error: The module '/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/build/Release/better_sqlite3.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 115. This version of Node.js requires NODE_MODULE_VERSION 119. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). at process.func [as dlopen] (node:electron/js2c/node_init:2:2214) at Module._extensions..node (node:internal/modules/cjs/loader:1356:18) at Object.func [as .node] (node:electron/js2c/node_init:2:2214) at Module.load (node:internal/modules/cjs/loader:1126:32) at Module._load (node:internal/modules/cjs/loader:967:12) at c._load (node:electron/js2c/node_init:2:13672) at v._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:176:5607) at i._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:173:29719) at t._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:35317) at Module.require (node:internal/modules/cjs/loader:1150:19) at require (node:internal/modules/cjs/helpers:119:18) at bindings (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:33995:52) at new Database2 (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:34621:69) at _SqliteDb.get (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:144644:20) at getSavedItemsForTag (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:144650:23) at getAddRemoveForTag (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:144660:23) at getComputeDeleteAddRemove (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:144753:45) at CodebaseIndexer.refresh (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:146423:47) at async RefreshCodebaseIndex.refreshCodebaseIndex (/Users/caoyf001/Desktop/gitlab/other/vscode-ai-extension/vscode/dist/extension.node.js:146504:22)

i try:

  1. change node version
  2. delete node-modules and lock.json then npm redownload
  3. cd node_modules/better-sqlite3 npm install
  4. delete $HOME/.node-gyp then redownload or rebuild

None of these attempts worked I am close to breaking down now, how can I solve this problem

Prinzhorn commented 1 month ago

See https://github.com/WiseLibs/better-sqlite3/issues/385 and related issues that can be found via the search. Using native modules in a vs code extension is probably painful...

I am close to breaking down now, how can I solve this problem

...as you probably know by now