microsoft / inshellisense

IDE style command line auto complete
MIT License
8.22k stars 180 forks source link

ReferenceError: window is not defined #144

Closed qokelate closed 5 months ago

qokelate commented 6 months ago

Describe the bug

$> is
/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1
........
........

ReferenceError: window is not defined
    at 226 (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:59021)
    at i (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:138036)
    at 92 (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:63176)
    at i (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:138036)
    at 295 (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:80366)
    at i (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:138036)
    at 744 (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:116918)
    at i (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:138036)
    at 969 (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:3196)
    at i (/usr/local/lib/node_modules/@microsoft/inshellisense/node_modules/xterm-headless/lib-headless/xterm-headless.js:1:138036)

Node.js v21.4.0
node-gyp@10.0.1  /usr/local/lib/node_modules/node-gyp
node@21.4.0

To Reproduce Steps to reproduce the behavior:

  1. type is command

Expected behavior A clear and concise description of what you expected to happen.

Environment

Additional context Add any other context about the problem here.

alanhe421 commented 6 months ago

app is terminal?iterm2?

It is recommended to add the app information.

I think you can try using node v20.

Lippiece commented 6 months ago

app is terminal?iterm2?

It is recommended to add the app information.

I have the same problem, Hyper and Gnome terminals. Fish, Bash and zsh.

qokelate commented 6 months ago

app is terminal?iterm2?

It is recommended to add the app information.

I think you can try using node v20.

I found this https://stackoverflow.com/questions/45964178/referenceerror-window-is-not-defined-at-object-anonymous-node-js, so i add const window = globalThis; to js file, got issue

$> is
inshellisense session [live]
__is_update_cwd:1: command not found: __vsc_escape_value

so it only working under vscode?

btw: app is iterm2

CarterLi commented 6 months ago

Same issue here.

The exception was thrown inside the dependency xterm-headless

https://github.com/xtermjs/xterm.js/blob/HEAD/src/common/TaskQueue.ts#L145

For some reason the isNode variable was false so that xterm-headless tried to access the browser only global object window which is not available in node.

The isNode is set here

https://github.com/xtermjs/xterm.js/blob/master/src/common/Platform.ts#L17

The code is correct. process is a nodejs only global object so that isNode should be set to true. There must be some other weird issues. I don't want to investigate it in depth and my first inshellisense experiment ends here.

cereschen commented 6 months ago

Lower your node version,node 21+ is not support

bdmorin commented 5 months ago

Lower your node version,node 21+ is not support

https://github.com/microsoft/inshellisense?tab=readme-ov-file#requirements CleanShot 2024-01-29 at 14 18 13

Might want to update requirements.