14

I use Emacs 24.2. I've installed js-comint and js-mode from MELPA, executed run-js, and now in REPL instead of > sign i have this gibberish:

^[[1G> ^[[0K^[[3G

The REPL itself in Inferior Javascript mode works just fine, just the > sign is changed. If you enter unfinished expression, it even prints ^[[1G... ^[[0K^[[5G. The ^[ are system characters, that are not copied with copy-paste, i add them for you to have an idea.

In my init-file:

(require 'js-comint)
(setq inferior-js-program-command "nodejs")

In terminal calling nodejs produces working REPL.

Why prompt behaves this way? What should i do to correct this?

Mirzhan Irkegulov
  • 17,660
  • 12
  • 105
  • 166

3 Answers3

20

Just add one line in your .emacs:

(setenv "NODE_NO_READLINE" "1")

Answer come from this post: Node.js prompt '>' can not show in eshell

Community
  • 1
  • 1
tangxinfa
  • 1,410
  • 13
  • 12
  • +1. this basically worked for me, thanks. I created a file named 'repl' in my app directory, and in it put NODE_NO_READLINE=1 node. Then just call ./repl from within an emacs shell and you get a node repl inside emacs with correct module scoping and no output giberrish. – Scott Klarenbach Sep 11 '15 at 03:24
18
(setq inferior-js-mode-hook
      (lambda ()
        ;; We like nice colors
        (ansi-color-for-comint-mode-on)
        ;; Deal with some prompt nonsense
        (add-to-list
         'comint-preoutput-filter-functions
         (lambda (output)
           (replace-regexp-in-string "\033\\[[0-9]+[GK]" "" output)))))

\033 is the escape character it prints as ^[.

2

Not sure how recent, but now one can download and use the nodejs-repl.

nymo
  • 532
  • 1
  • 5
  • 14