如何在 Eclipse 控制台中运行 script.js?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37743948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I run script.js in Eclipse console?
提问by Olga
回答by ebbishop
To set up Eclipse to run JavaScript files:
设置 Eclipse 以运行 JavaScript 文件:
In Eclipse, got to Run > External Tools > External Tool Configurations
Double click on Program to open a new configuration and name your new configuration (ex. Node_Config)
Figure out where you have node.js installed. Paste the results in the 'Location' box in Eclipse. (If you haven't installed node, do so here)
- Mac:in the command line, run
which node
. - Windows:in the command line, run
where node
, or see this for more/different windows advice
- Mac:in the command line, run
Fill in the following:
- Working Directory: ${container_loc}
- Arguments: ${resource_name}
Click apply, and then close.
在 Eclipse 中,转到运行 > 外部工具 > 外部工具配置
双击 Program 打开一个新配置并命名您的新配置(例如 Node_Config)
找出您安装了 node.js 的位置。将结果粘贴到 Eclipse 的“位置”框中。(如果您还没有安装节点,请在此处安装)
- Mac:在命令行中,运行
which node
. - Windows:在命令行中,运行
where node
,或查看更多/不同的 Windows 建议
- Mac:在命令行中,运行
填写以下内容:
- 工作目录:${container_loc}
- 参数:${resource_name}
单击应用,然后关闭。
Now, in the main Eclipse screen, find the play button with a red toolbox (next to the regular play button). When you have a js file open that you want to run, click this and it will be just like running it from your console using node.
现在,在主 Eclipse 屏幕中,找到带有红色工具箱的播放按钮(在常规播放按钮旁边)。当您打开要运行的 js 文件时,单击它,就像使用 node.js 从控制台运行它一样。
回答by Angelo
Since Eclipse Neon you can do that. I suggets you that you
由于 Eclipse Neon,您可以做到这一点。我建议你
- download Eclipse Neonand install Eclipse JEE Neondistribution.
- install node.js.
- 下载Eclipse Neon并安装Eclipse JEE Neon发行版。
- 安装node.js。
With Eclipse JEE Neon, you will benefit with Run As / Node.js Applicationand even with Debug As / Node.js Application:
使用 Eclipse JEE Neon,您将受益于Run As / Node.js Application甚至是Debug As / Node.js Application:
回答by Arpit Goyal
He is using WebStorm which is editor for Front-end dev from same company (JetBrains).
他正在使用 WebStorm,它是同一家公司 (JetBrains) 的前端开发编辑器。