Xterm.js: how to use in angular2 app (service)

Created on 5 Jan 2017  路  8Comments  路  Source: xtermjs/xterm.js

I have angular2 service that must provide tty console to some vm.
How can i import xterm only for this service ?
If i write import { Xterm } from 'xterm'; i get error

ERROR in ./src/app/ttycon.service.ts                                                                                                                   Module build failed: Error: /var/home/vtolstov/devel/panel/src/app/ttycon.service.ts (2,10): Module '"/var/home/vtolstov/devel/panel/node_modules/@types/xterm/index"' has no exported member 'Xterm'.)
    at _checkDiagnostics (/var/home/vtolstov/devel/panel/node_modules/@ngtools/webpack/src/loader.js:116:15)
    at /var/home/vtolstov/devel/panel/node_modules/@ngtools/webpack/src/loader.js:141:17
 @ ./src/app/ttycon/ttycon.component.ts 11:0-50
 @ ./src/app/app.module.ts
 @ ./src/main.ts                                                                                                                                        
@ multi main

I have installed xterm and @types/xterm

Most helpful comment

import * as xterm from 'xterm'
Works

All 8 comments

I believe you want:

import { Terminal } from 'xterm';

This is not worked.

May be @types/xterm wrong?

Actually try this one:

import * as xterm from 'xterm'

This is how I import it in vscode:

import xterm = require('xterm');
...
new xterm()

import * as xterm from 'xterm'
Works

Thanks!

@Tyriar How about importing addons?

@Kaijun there is a loadAddon function for node but it's not officially part oft he API yet so it may change across versions (pending #306).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jestapinski picture jestapinski  路  3Comments

zhangjie2012 picture zhangjie2012  路  3Comments

jerch picture jerch  路  3Comments

tandatle picture tandatle  路  3Comments

chris-tse picture chris-tse  路  4Comments