cronvel / terminal-kit

Terminal utilities for node.js
MIT License
3.08k stars 198 forks source link

Impossible to compile with pkg #205

Closed el2zay closed 1 year ago

el2zay commented 2 years ago

Hello, I try to compile my script in executable with the pkg module but the problem is that at the time of launching the executable this error is displayed:

image

(Screen on macOS catalina)

I have this error only when there is terminal kit in my code when I remove it everything works again. I have no idea if the problem comes from terminal kit or from pkg which manages terminal kit badly.

djkato commented 2 years ago

I have the exact same issue, with no idea how to fix it. I opened an issue in PKGs github too but got ignored. My issue on pkg: #vercel/pkg#1619 similliar ones:

vercel/pkg#1018

nexe/nexe#509

This apparently helps, but I couldn't get it to work no matter what I tried: https://stackoverflow.com/a/56909415

alexn-s commented 2 years ago

+1

Tonours commented 2 years ago

Hello! I had the same issue, and i've been able to fixed it by adding the terminal-kit node_modules into the assets of pkg, as follow

"pkg": {
    "assets": [
      "../../node_modules/terminal-kit/**/*"
    ]
  },
cronvel commented 2 years ago

@el2zay @djkato @alexn-s @Tonours Sorry for being late.

Terminal-Kit uses dynamic require(), so your packager needs to include everything. I don't know pkg, but @Tonours 's solution seems to be the way to go, except that you should change "../../node_modules/terminal-kit/**/*" into "../../node_modules/terminal-kit/lib/**/*".

All the lib code is in the lib/ subdirectory.