This page needs attention!


Node-JS is a Javascript runtime enviroment, popular for making async web and TCP servers. There are several modes for running node.js inside of Emacs:

Using comint mode

The simplest method is to just use Emacs’s Comint mode:

    (defun node-repl () (interactive)
      (setenv "NODE_NO_READLINE" "1") ;avoid fancy terminal codes
      (pop-to-buffer (make-comint "node-repl" "node" nil "--interactive")))

Using js-comint

“The simplest way to have node.js as an inferior shell under Emacs is to use the js-comint package. The command M-x run-js will then open the interpreter.”

If you start a repl using “js-comint-repl”, you can then later send code to the repl using “js-comint-send-region”. (Please note original commands like `js-run` and `js-send-region` are alias of new `js-comint-xxxx` commands).

Using nodejs-repl

Size: 27KB

Using SwankJs

see SwankJs for details.

What are the advantages to using SwankJs?

There’s still no tab-completion.

Using nodejs-mode

There is a node.js mode. As of 2013-04-15 it has not been updated for Node.js 0.8 or later.

Question: But does it still work with newer versions of node.js ?

I tested this on 2013.04.29 with Win7, Emacs 24 and node.js 0.10.5. A shell is opened, once something is sent to node node is actually launched, but Emacs does not respond to any more input until I kill the node process externally.

Some links

See Also

CategoryJavaScript CategoryProgramming CategoryNeedsAttention