My executable file that i compiled with nexe on NodeJS not works on a different location

78 Views Asked by At

Note that i’m using NodeJS v16.16.0

When utilizing nexe to compile my file, everything works as expected until I attempt to change the file location at that point, the program ceases to function. Seeking guidance on resolving this issue.

It looks like that is caused by sqlite3 import, so I have still imported it with Nexe using the -r node_sqlite3.node option located in the node_modules folder in this manner, and it still does not work.

"compile": "nexe ./vare.js -r node_modules/sqlite3/build/Release/node_sqlite3.node -o compiled --build"

This line is located at my package.json

When i execute my compiled .exe, It works when the executable is located at the directory where i builded it so if i change to another directory it shows this error :

C:\Users\Administrator\Documents>compiled.exe
C:\Users\Administrator\Documents\node_modules\bindings\bindings.js:211
      throw new Error(
      ^

Error: Could not find module root given file: "C:\Users\Administrator\Documents\node_modules\sqlite3\lib\sqlite3-binding.js". Do you have a `package.json` file?
    at Function.getRoot (C:\Users\Administrator\Documents\node_modules\←[4mbindings←[24m\bindings.js:211:13)
    at bindings (C:\Users\Administrator\Documents\node_modules\←[4mbindings←[24m\bindings.js:82:32)
    at Object.<anonymous> (C:\Users\Administrator\Documents\node_modules\←[4msqlite3←[24m\lib\sqlite3-binding.js:1:37)
←[90m    at Module._compile (node:internal/modules/cjs/loader:1105:14)←[39m
←[90m    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)←[39m
←[90m    at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m
←[90m    at Module.require (node:internal/modules/cjs/loader:1005:19)←[39m
←[90m    at require (node:internal/modules/cjs/helpers:102:18)←[39m
    at Object.<anonymous> (C:\Users\Administrator\Documents\node_modules\←[4msqlite3←[24m\lib\sqlite3.js:2:17)
0

There are 0 best solutions below