Create a node.js target for xterm.js
See original GitHub issueDetails
- OS version: node
- xterm.js version: 4.4.0
> require('xterm')
Thrown:
ReferenceError: window is not defined
at Object.<anonymous> (/private/tmp/test/node_modules/xterm/lib/xterm.js:1:224)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
Steps to reproduce
https://runkit.com/embed/q7w97d0b8wj2
Looks like webpack4 bug, See: https://medium.com/@JakeXiao/window-is-undefined-in-umd-library-output-for-webpack4-858af1b881df
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:24 (23 by maintainers)
Top Results From Across the Web
It's possible to xterm.js on nodejs server side? - Stack Overflow
I'm creating a mutiplex terminal on NodeJs, for rendering data to StdOut i'm using terminal.js, but it is a little bit glitchie, ...
Read more >Creating A Browser-based Interactive Terminal (Using ...
Creating A Browser-based Interactive Terminal (Using XtermJS And NodeJS). Why a terminal in the browser? A browser-based terminal has a lot of use...
Read more >billchurch/webssh2: Web SSH Client using ssh2, socket.io ...
Web SSH Client using ssh2, socket.io, xterm.js, and express. A bare bones example of an HTML5 web-based terminal emulator and SSH client.
Read more >Setting up a Go backend for Xterm.js to get a shell over the ...
In terms of steps, I needed to build the binary, pull in dependencies for the frontend, and get artifacts from both the previous...
Read more >Process | Node.js v19.3.0 Documentation
Normally, the Node.js process will exit when there is no work scheduled, but a listener registered on the 'beforeExit' event can make asynchronous...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Good progress has been made on this. I’m not sure just yet how we’ll end up publishing the module though as ./package.json in the root is xterm and points at typing/xterm.d.ts. I want to be able to publish
xterm-core
with a totally separate set of typings, readme and package.json while at the same time don’t really want to include that in the src/ directory.I’d also love it if xterm supported node. I originally thought node is supported, since xterm can already run in “headless” mode: https://github.com/xtermjs/xterm.js/issues/266 , without being attached to a DOM.
I tried a simple workaround in my code, just setting
global.window = undefined
beforerequire('xterm')
and that fixed theReferenceError
and everything is working as expected. It’s just a pain to have to set that everywhere, including in tests.Awesome work on xterm by the way 🙂
Edit: this is what got me to think Node.js should work 🙂 https://github.com/xtermjs/xterm.js/blob/master/src/Terminal.ts#L70-L71 :