how to run node.js interactively in Emacs on Windows

The simplest way to have node.js (tested using node v0.8.1) as an inferior shell under Emacs is to use the js-comint package. Then, set (setq inferior-js-program-command "node --interactive") to force node to run in interactive mode. The command M-x run-js will then open the interpreter.

Similarly, you can easily verify that node --interactive works within an eshell.


I found one solution.

Make a node script which starts a JavaScript REPL interface.

node-in-node.js:

var repl = require("repl");
repl.start();

Pass "node path\to\node-in-node.js" to make-comint instead of simply "node".

(defun my-node-shell ()
  (interactive)
  (pop-to-buffer (make-comint "Node Shell" "node" nil "C:\\run\\node-in-node.js")))

Run M-x my-node-shell to run a JavaScript shell in Windows Emacs. I don't know why this works. Tab completion, syntax highlight, multiline input via Shift+Enter does not work.


From http://www.gnu.org/software/emacs/windows/Sub_002dprocesses.html , it looks as if what may be happening is that the output is being buffered by node. If there is an option that modifies it's buffering, you could try passing that.

There may be another way to solve it, assuming it's a buffering issue, but my windows lore isn't nearly complete enough to know. I, for one, would love a general solution to this on windows platforms, it's an annoying problem when it crops up.