简体   繁体   中英

How to change the repl prompt of node.js?

node.js 's default repl prompt is > , I sometimes type shell commands into it. In order to easily distinguish it from other programming language repl's and shell prompts, I would like to change it to something like node > . Is it possible, or is there any better practice on this problem?

Create a small node program which fires up a REPL and specifies prompt: 'node >' in the options hash.

See docs here .

// repl.js
const repl = require('repl');
var replServer = repl.start({prompt: 'node > '});

$ node repl.js
node >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM