Better-sqlite3: Custom configuration on Windows 10

Created on 4 Sep 2019  路  5Comments  路  Source: JoshuaWise/better-sqlite3

Hi,

I'm currently working on a Capacitor Plugin using better-sqlite3 for the Electron platform.

So far everything is working great and I've got great performances on Electron.

Now i'm trying to add the possibility to encrypt the database. I chose sqleet to do so. I followed this documentation and I've got the following error when executing the command on Windows 10 :
npm i better-sqlite3 --sqlite3=D:\dev\ionic\sqlite-snapshot

Error output :

D:\dev\ionic\all-platform-build>npm i better-sqlite3 --sqlite3=D:\dev\ionic\sqlite-snapshot

> [email protected] install D:\dev\ionic\all-platform-build\node_modules\better-sqlite3
> node-gyp rebuild


D:\dev\ionic\all-platform-build\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "D:\.node_modules\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "D:\.node_modules\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
  symlink_sqlite3
  fs.js:126
      throw err;
      ^

CUSTOMBUILD : error : ENOENT: no such file or directory, access '\D:\dev\ionic\sqlite-snapshot\sqlite3.c' [D:\dev\ionic\all-platform-build\node_mo
dules\better-sqlite3\build\deps\locate_sqlite3.vcxproj]
      at Object.accessSync (fs.js:202:3)
      at Object.<anonymous> (D:\dev\ionic\all-platform-build\node_modules\better-sqlite3\deps\symlink.js:14:5)
      at Module._compile (internal/modules/cjs/loader.js:776:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
      at Module.load (internal/modules/cjs/loader.js:643:32)
      at Function.Module._load (internal/modules/cjs/loader.js:556:12)
      at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
      at internal/main/run_main_module.js:17:11 {
    errno: -4058,
    syscall: 'access',
    code: 'ENOENT',
    path: '\\D:\\dev\\ionic\\sqlite-snapshot\\sqlite3.c'
  }
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\.node_modules\node_modules\npm\node_modules\node-gyp\lib\build.js:196:23)
gyp ERR! stack     at ChildProcess.emit (events.js:203:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\.node_modules\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\dev\ionic\all-platform-build\node_modules\better-sqlite3
gyp ERR! node -v v12.6.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok

After a quick look at this file, I guess the line const source = path.join(path.sep, process.argv[3]); is returning an incorrect path for Windows system.

Thanks

bug

Most helpful comment

Patched in v5.4.3.

All 5 comments

@DrDonkeyPunch, can you try it with --sqlite3=\dev\ionic\sqlite-snapshot?

Hi! I ran into this issue as well, and adding a \ at the start did indeed work.

If the intention is to get an absolute path, perhaps path.resolve would be a better choice than path.join(path.sep, ...)? :)

Yup, I can confirm that path.resolve() seems to fix the issue. I'll get that patched soon.

Patched in v5.4.3.

I just installed the latest version. v5.4.3 fixes the issue.

Your first suggestion worked as well.

Thanks for your reactivity.

Was this page helpful?
0 / 5 - 0 ratings