Fixes

Software errors, minor annoyances and unique fixes live here!

Node 13 / 12 pgk terminal-kit error cannot find module xterm.generic.js

Have you ever tried to build a terminal-kit app in Node using pkg to generate a nice easy application binary but instead face this error?

Error: Cannot find module './termconfig/xterm.generic.js'
Require stack:
- /snapshot/remotecow/node_modules/terminal-kit/lib/Terminal.js
- /snapshot/remotecow/node_modules/terminal-kit/lib/termkit.js
- /snapshot/remotecow/app/term.js
- /snapshot/remotecow/app/commands.js
- /snapshot/remotecow/app/app.js
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:795:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1287:46)
    at Function.Module._load (internal/modules/cjs/loader.js:688:27)
    at Module.require (internal/modules/cjs/loader.js:850:19)
    at Module.require (pkg/prelude/bootstrap.js:1166:31)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.createTerminal (/snapshot/remotecow/node_modules/terminal-kit/lib/Terminal.js:159:18)
    at terminal (/snapshot/remotecow/node_modules/terminal-kit/lib/termkit.js:103:18)
    at Object.get [as terminal] (/snapshot/remotecow/node_modules/lazyness/lib/Lazyness.js:48:16)
    at new Term (/snapshot/remotecow/app/term.js)

I did today! And after a bunch of Googling I still couldn't find the answer and instead found one vague reference.

Luckily after much experimenting I managed to fix it.

Simply add the following to your package.json and also remember to add it to your pkg build command so you end up with something like this: pkg package.json -t node12-linux

  "pkg": {
    "assets": "node_modules/terminal-kit/**/*"
  }

And there you have it, headache over and your executable should now stop throwing errors.

The reason for all of this is that the require statements inside of terminal-kit are unique and don't follow the norm, so instead we grab everything inside the module.