Closed
Description
- Version: v4.4.5
- Platform: Linux lts 4.4.0-24-generic The binary and long term compatibility with node #43-Ubuntu SMP Wed Jun 8 19:27:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem:
When I try this demo
// repl_test.js
const repl = require('repl');
var replServer = repl.start({});
replServer.defineCommand('sayhello', {
help: 'Say hello',
action: function(name) {
this.write(`Hello, ${name}!\n`);
this.displayPrompt();
}
});
then run this in my command line with node repl_test.js
// and got the output with
.sayhello Node.js User
Hello, Node.js User!
SyntaxError: Unexpected identifier
at Object.exports.createScript (vm.js:24:10)
at REPLServer.defaultEval (repl.js:235:25)
at bound (domain.js:287:14)
at REPLServer.runBound as eval
at REPLServer. (repl.js:431:12)
at emitOne (events.js:77:13)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:885:20)
It got the synatax error, and I don't know why?