如何在 Windows 上的 Emacs 中以交互方式运行 node.js [英] how to run node.js interactively in Emacs on Windows
问题描述
我认为这会奏效:
(defun my-node ()
(interactive)
(pop-to-buffer (make-comint "my-node" "node")))
但是当我执行 M-x my-node
并在 comint 缓冲区中输入 1+1
时,它不显示任何输出.
But when I do M-x my-node
and enter 1+1
in the comint buffer, it does not display any output.
这是在 Windows 7 上的 Emacs 24.0.50.1 中,无需任何特殊配置即可安装 NodeJS.
This is in Emacs 24.0.50.1 on Windows 7 and NodeJS is installed without any special configuration.
以非交互方式调用 node.js,如 M-x compile RET node hello-world.js RET
工作正常.在 cmd
中以交互方式运行 node
工作正常.
Calling node.js non-interactively as in M-x compile RET node hello-world.js RET
works fine. Running node
interactively in cmd
works fine.
这可能是相关的:当我运行 Mx shell
并在 shell 缓冲区中输入 node
然后输入 1+1
时,它不会'不显示结果.我一定遗漏了一些非常基本的东西.
This might be related: when I run M-x shell
and enter node
in the shell buffer and then enter 1+1
, it doesn't display the result. I must be missing something very basic.
更新:
可能相关:emacs/Python:在行缓冲与块缓冲模式下运行python-shell - 代码日志
Probably related: emacs/Python: running python-shell in line buffered vs. block buffered mode - Stack Overflow
推荐答案
我找到了一个解决方案.
I found one solution.
制作一个启动 JavaScript REPL 接口的节点脚本.
Make a node script which starts a JavaScript REPL interface.
node-in-node.js:
node-in-node.js:
var repl = require("repl");
repl.start();
将node path o ode-in-node.js"传递给 make-comint 而不是简单的node".
Pass "node path o ode-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")))
运行 M-x my-node-shell
在 Windows Emacs 中运行 JavaScript shell.我不知道为什么会这样.制表符补全、语法高亮、Shift+Enter 多行输入不起作用.
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.
这篇关于如何在 Windows 上的 Emacs 中以交互方式运行 node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!