Run a JavaScript interpreter in an inferior process window
Emacs Lisp
Switch branches/tags
Nothing to show
Pull request Compare This branch is even with redguardtoo:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

js-comint.el (v1.1.0)

Run a JavaScript interpreter in an inferior process window

The first release, js-comint 0.0.1, is hosted on sourceforge but it has not been updated for five years.



Direct download of js-comint.el

Place the js-comint.el somewhere say “~/mylisp/”.

Insert below code to “~/.emacs.d/init.el”,

(add-to-list 'load-path "~/mylisp/")
(require 'js-comint)

Using ELPA

Insert below code to “~/.emacs.d/init.el”,

(require 'package)
(add-to-list 'package-archives
             '("melpa" . ""))
(package-install 'js-comint)
(require 'js-comint)

Using Cask

Add js-comint to your Cask file:

(depends-on "js-comint")


After installation, do `M-x run-js` to create a comint buffer with the JavaScript interpreter.

Please note the directory node_modules is automatically searched and appended into environment variable `NODE_PATH’. So you can use third party javascript without setup. For example, after npm install --save moment, run below command in js-comint shell,


You can M-x js-clear before M-x js-send-buffer to get clean output.

In order to get cleaner output when using NodeJS, I suggest add below setup into .emacs,

(defun inferior-js-mode-hook-setup ()
  (add-hook 'comint-output-filter-functions 'js-comint-process-output))
(add-hook 'inferior-js-mode-hook 'inferior-js-mode-hook-setup t)


You can set the `inferior-js-program-command’ string and the `inferior-js-program-arguments’ list to the executable that runs the JS interpreter and the arguments to pass to it respectively.

E.g., the default is:

;; You can also customize `js-comint-drop-regexp' to filter output
(setq inferior-js-program-command "node")
(setq inferior-js-program-arguments '("--interactive"))

Note that in the example above, the version of node that is picked up will be the first found in `exec-path’.

But you could use Rhino or SpiderMonkey or whatever you want. E.g. to set up the Rhino JAR downloaded from, do

(setq inferior-js-program-command "java")
(setq inferior-js-program-arguments '("-jar" "/absolute/path/to/rhino/js.jar"))

If you have nvm, you can select the versions of node.js installed and run them. This is done thanks to nvm.el. nvm.el is optional. So you need manually install it.

To enable nvm support, run


The first time you start the JS interpreter with run-js, you will be asked to select a version of node.js. If you want to change version of node js, run `(js-select-node-version)`

You can add the following couple of lines to your .emacs to take advantage of cool key bindings for sending things to the javascript interpreter inside of Steve Yegge’s most excellent js2-mode.

(add-hook 'js2-mode-hook
          (lambda ()
            (local-set-key (kbd "C-x C-e") 'js-send-last-sexp)
            (local-set-key (kbd "C-M-x") 'js-send-last-sexp-and-go)
            (local-set-key (kbd "C-c b") 'js-send-buffer)
            (local-set-key (kbd "C-c C-b") 'js-send-buffer-and-go)
            (local-set-key (kbd "C-c l") 'js-load-file-and-go)))