nexe/nexe

The generated executable is not standalone

mcuong223 opened this issue · 4 comments

I expect a fully standalone exe that is completely independent of the required node modules
I tried a lot of options/methods but still not work. The exe file can run in the initial directory, but when I copy it to other directory,
it can not run and will throws an error indicates that a module could not be found, such as (sqlite3):

~\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64\node_sqlite3.node Error: The specified module could not be found.

I tried many methods including NodeJS API and command line

Environment:

  • Platform(OS/Version): Windows 11 Home 64-bit (10.0, Build 22621)
  • Host Node Version: 14.20.0
  • Target Node Version:14.20.0
  • Nexe version: 4.0.0-rc.2
  • Python Version: 2.7.15

some of the binary that your program depended on it can not be compiled by nexe
you need to manually move the dependent binary to your executable directory for it to run

in your case you need to node_sqlite3.node to the executable directory for it to work
specifically you need to move the node_sqlite3.node into {EXEDIR}\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64
as shown in the error message

I ran into this error all the time with puppeteers or any dependence that needs binary files

again, in your case, the sqlite3 driver is looking for lib written in c++ compiled into node addon in a file called node_sqlite3.node
in a directory called \node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-x64
but the module can not find it in the executable directory

after moving the binary file (node_sqlite3.node) into the desired location
your program will run 100% without using the node
it will work on any device that does not have a node on it

thanks @abdelrahman-tarek-0 for the reply, but I want the exe can run not only without nodejs but also without other files

thanks @abdelrahman-tarek-0 for the reply, but I want the exe can run not only without nodejs but also without other files

this is not possible you have to include any exe or binary files into your executable directory
however, nexe provides a resource flag (-r) this option is for you to include any read-only assets your app need
again it is read-only binaries, for example (images your app is serving, any plane text "read-only" )
see this section for the resource flag here

the resource flag is very limited and in your case, the sqlite3 driver needs more than read-only data
so in your case, the -r flag will not work

SO IN YOUR CASE, YOU HAVE TO PUT THE BINARY INTO YOUR EXECUTABLE DIRECTORY

thanks @abdelrahman-tarek-0 for the reply, but I want the exe can run not only without nodejs but also without other files

this is not possible you have to include any exe or binary files into your executable directory however, nexe provides a resource flag (-r) this option is for you to include any read-only assets your app need again it is read-only binaries, for example (images your app is serving, any plane text "read-only" ) see this section for the resource flag here

the resource flag is very limited and in your case, the sqlite3 driver needs more than read-only data so in your case, the -r flag will not work

SO IN YOUR CASE, YOU HAVE TO PUT THE BINARY INTO YOUR EXECUTABLE DIRECTORY

I got it, thank you so much for letting me know, I thought nexe can packaging every into single exe. I will close the issue here!