criblio / js2bin

NodeJS application to native executable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Q: How do I include additional node package dependencies into the binary?

20excal07 opened this issue · comments

commented

My Node application requires to first install packages axios, asyncawait, and fibers as they depend on them. How do I make sure that those packages are included in the binary when I build it? It doesn't seem to be explained in your Readme.

It throws this error when I tried to run it:

[centos@centos8 js2bin]$ ./4gSimulator-linux-x64 
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'axios'
Require stack:
- /home/centos/js2bin/4gSimulator.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/home/centos/js2bin/4gSimulator.js:16:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at _third_party_main.js:30:5
    at NativeModule.compileForInternalLoader (internal/bootstrap/loaders.js:286:7)
    at nativeModuleRequire (internal/bootstrap/loaders.js:315:14)
    at internal/main/run_third_party_main.js:12:3 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/centos/js2bin/4gSimulator.js' ]
}

You need to bundle your app and the dependencies into a single js file using webpack or any other bundler.