I am using nodejs-repl.el with Emacs and nodejs to evaluate JavaScript code. Everything has been fine until I tested the following code:
//define a Mammal psuedo-class
var Mammal = function (name) { this.name = name; };
Mammal.prototype.get_name = function ( ) { return this.name; };
Mammal.prototype.says = function ( ) { return this.saying || ''; }; //!problem line
The above code is from the book "JavaScript, the good parts". It runs in every other environment I tested: node-repl
on the command line, the online https://babeljs.io/repl . But it fails in Emacs with nodejs-repl.el
.
The problem is with the last line, from which I get the following error:
> Mammal.prototype.says = function ( ) { return this.saying ''; };
SyntaxError: repl: Unexpected token, expected ; (1:61)
> 1 | Mammal.prototype.says = function ( ) { return this.saying ''; };
| ^
Can anyone please help explain what went wrong and how to fix my Emacs environment (nodejs-repl.el)?
My Emacs (24.5 Ubuntu 16.04) configuration is below:
(require 'comint)
(add-to-list 'comint-preoutput-filter-functions
(lambda (output)
(let ((case-fold-search nil))
(replace-regexp-in-string "\033\\[[0-9]+[A-Z]" "" output))))
(setq babel-repl-cli-arguments '("--presets" "es2015" ))
via tinlyx
No comments:
Post a Comment