Node.js

Node.js has a built-in REPL with syntax highlighting. The quickest way to use it is with the built-in profile:

extensions:
  term:
    profile: node

This sets shell: node, prompt: ">", and ps2: "...". You may want to override ps2 to match Node’s actual continuation character:

extensions:
  term:
    profile: node
    ps2: "|"

Basic Usage

console.log("Hello from Node.js " + process.version)
Hello from Node.js v22.23.1
undefined

Expressions

1 + 1
2
Math.PI * 2
6.283185307179586

Objects and Arrays

const data = {name: "quarto-term", version: "0.4.3", shells: 10}
undefined
data
{ name: 'quarto-term', version: '0.4.3', shells: 10 }
[1, 2, 3, 4, 5].map(x => x * x)
[ 1, 4, 9, 16, 25 ]

Functions

function fibonacci(n) {
...

Promises

... await Promise.all([1, 2, 3].map(x => Promise.resolve(x * 10)))
...