Reputation: 846
NodeRED
I am looking to use the xterm.js library from https://xtermjs.org/, which I installed with the command npm install xterm
.
I would like to use the template node to run the following code but I do not know how to import the xterm.js library.
<link rel="stylesheet" href="what-path-do-i-use/xterm/css/xterm.css" />
<script src="what-path-do-i-use/xterm/lib/xterm.js"></script>
<div id="terminal"></div>
<script>
var term = new Terminal();
term.open(document.getElementById('terminal'));
term.write('Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ')
</script>
I used docker-compose to launch the project:
docker-compose.yml
version: "3.7"
services:
node-red:
image: nodered/node-red:latest
user: root
environment:
- TZ=America/New_York
ports:
- "1880:1880"
networks:
- node-red-net
volumes:
- .node-red-data:/data
networks:
node-red-net:
Not looking to CDN
A CDN link like below is a temp solution, but there should be a way to reference npm modules libraries.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.5/xterm.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.14.5/xterm.min.js"></script>
Upvotes: 0
Views: 1105
Reputation: 59866
Node-RED won't just serve up files from npm installed modules. You will have to do one of the following:
httpStatic
path in your settings.js
file (path to this is listed in the early log output) and place the xterm.js
file in that path. It can then be accessed with something like http:localhost:1880/xterm.jsxterm.js
file.You haven't said which directory you were in when you ran the npm install
so I can't suggest where the file will have ended up.
Upvotes: 2