简体   繁体   中英

node.js in emacs buffer has no process---better system to execute js interactively in emacs

I am trying to set up a nodejs dev environment in emacs, but having some trouble navigating the differences between:

  • node-repl
  • nodejs-repl
  • nodejs-repl-mode and
  • javascript-mode

...and how I should combine these to have command line execution, syntax highlighting, and autocomplete---the sort of things I have set up with say, python or generally using emacs for development.

I think I am currently using nodejs-mode with REPL.

I have the following script I am trying to execute, just to see if I can get simple Cc Cc evaluation to work. It seems, however, that my javascript-editing buffer, right pane, is not connected to my nodejs execution buffer, left pane:

在此处输入图片说明

I understand I could probably just rebind some keys so Cc Cc sends to the interactive nodejs buffer---but it's unclear to me how to generally attach that process, or even what that function would be called. (And it makes me suspect someone has probably done this before much better than I would!)

I have configured my setup for node.js a few days ago. I use:

They are both available through MELPA .

After you install js-comint add:

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

and for the keys:

(add-hook 'js2-mode-hook 
          '(lambda ()
            (local-set-key (kbd "C-x C-e") 'js-send-last-sexp)
            (local-set-key (kbd "C-x C-r") 'js-send-region)
            (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)))

You can run the REPL with Mx run-js .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM