astefanutti / kubebox

⎈❏ Terminal and Web console for Kubernetes
http://astefanutti.github.io/kubebox
MIT License
2.14k stars 142 forks source link

Throw error "Cannot read property 'isAlt' of undefined" after run with built binary file #130

Closed Verten closed 2 years ago

Verten commented 2 years ago
~/kubebox/kubebox$ ./kubebox
/home/verten/kubebox/kubebox/__nexe_stdin.js:24482
  if (!this.program.isAlt) return;
                    ^

TypeError: Cannot read property 'isAlt' of undefined
    at Screen.leave (/home/verten/kubebox/kubebox/__nexe_stdin.js:24482:21)
    at Screen.destroy (/home/verten/kubebox/kubebox/__nexe_stdin.js:24584:8)
    at /home/verten/kubebox/kubebox/__nexe_stdin.js:24389:14
    at Array.forEach (<anonymous>)
    at process.on.Screen._exceptionHandler (/home/verten/kubebox/kubebox/__nexe_stdin.js:24388:30)
    at process.emit (events.js:310:20)
    at process._fatalException (internal/process/execution.js:164:25)

is any suggestion? thanks

astefanutti commented 2 years ago

I think that error happens when no entry can be found in the termcap file nor terminfo directory. The entry is looked up based on the value set for the TERM environment variable? Could you check what's it's value? Also, could you provide more info about your terminal / env?

Verten commented 2 years ago

Hi @astefanutti , thanks for the quick response. I try build executable file on linux, but it failed. And i checked the source file, after i put 'process.env.TERM': "'xterm-color'" in webpack.config.js. the built file can work fine.

But in window, it is still with error 'TypeError: Cannot read property 'isAlt' of undefined'.

And if i just run command 'npm run bundle' and try using node bundle.js

it still throw error with "TypeError: Cannot read property 'isAlt' of undefined" in window.

BTW, I using cmder as terminal. the TERM is

echo %TERM%
cygwin
astefanutti commented 2 years ago

I think running kubebox with TERM=xterm-color kubebox should also work, as an alternative to re-building the executable.

It's been a while since I've tried on Windows, but it's supposed to read the terminfo from the windows-ansi file. That file used to be embedded manually into the Windows executable, and it's possible I've messed it up in the latest release. Here is what I used to do:

$ base64 -i node_modules/blessed/usr/windows-ansi | pbcopy
# copy into the Tput._infoBuffer variable inside bundle.js

I've never tested it on Cygwin, and I wonder how windows-ansi terminfo is supposed to be looked up there.

Verten commented 2 years ago

Hi @astefanutti , thanks. I add one line to print the TERM variable.

I using windows terminal, and here is the output

npm run executable-windows

> kubebox@0.9.0 executable-windows /mnt/c/kubebox
> npm run bundle && cat bundle.js | nexe -t win-12.16.2 -o kubebox

> kubebox@0.9.0 bundle /mnt/c/kubebox
> webpack

[webpack-cli] Compilation finished
asset bundle.js 2.35 MiB [emitted] (name: main)
runtime modules 1.11 KiB 5 modules
modules by path ./node_modules/ 2.09 MiB 302 modules
modules by path ./lib/ 228 KiB
  modules by path ./lib/ui/ 149 KiB 33 modules
  modules by path ./lib/*.js 49.5 KiB 10 modules
  modules by path ./lib/config/*.js 21.2 KiB 6 modules
  modules by path ./lib/auth/*.js 7.93 KiB
    ./lib/auth/exec.js 2.49 KiB [built] [code generated]
    ./lib/auth/gcp.js 2.18 KiB [built] [code generated]
    ./lib/auth/oidc.js 3.26 KiB [built] [code generated]
18 modules
webpack 5.4.0 compiled successfully in 3093 ms
ℹ nexe 4.0.0-beta.14
✔ Already downloaded...
✔ Compiling result
✔ Entry: '[stdin]' written to: kubebox.exe
✔ Finished in 0.567s

ls -ltr | grep kubebox
-rwxrwxrwx 1 root root 32029675 Nov 26 18:12 kubebox.exe

after build the kubebox.exe file, I open CMD to run this file. and here is the output

C:\kubebox>kubebox.exe
TERM ->  windows-ansi
C:\kubebox\__nexe_stdin.js:24496
  if (!this.program.isAlt) return;
                    ^

TypeError: Cannot read property 'isAlt' of undefined
    at Screen.leave (C:\study\hackthon\2021\kubebox\__nexe_stdin.js:24496:21)
    at Screen.destroy (C:\study\hackthon\2021\kubebox\__nexe_stdin.js:24598:8)
    at C:\study\hackthon\2021\kubebox\__nexe_stdin.js:24403:14
    at Array.forEach (<anonymous>)
    at process.on.Screen._exceptionHandler (C:\study\hackthon\2021\kubebox\__nexe_stdin.js:24402:30)
    at process.emit (events.js:310:20)
    at process._fatalException (internal/process/execution.js:164:25)

Is there any suggestion? many thanks.

Verten commented 2 years ago

I found the root cause of this problem

    new CopyPlugin({
      patterns: [
        { from: "node_modules/blessed/usr/*", to: "usr/", flatten: true },
        {
          from: ".config", to: "js"
        }
      ],
    }),

update the webpack config to copy the blessed related file. and change build command to "executable-windows": "npm run bundle && cd dist/js && nexe -i bundle.js -t win-12.16.2 -o ../../kubebox-executable -r \"../usr/*\" -r \".config\""

astefanutti commented 2 years ago

Awesome, thanks a lot for the feedback! If you manage to create a PR, that'd be even more awesome! Thanks again.

Verten commented 2 years ago

Pull request