如何在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:12:08  来源:igfitidea点击:

How can I run script.js in Eclipse console?

javascriptnode.jseclipse

提问by Olga

Is it possible to do the same as thisin Eclipse what he is doing in Intellij IDEA? to run the javascript file in console?

是否有可能做同样为这个在Eclipse他在的IntelliJ IDEA是干什么的?在控制台中运行 javascript 文件?

回答by ebbishop

To set up Eclipse to run JavaScript files:

设置 Eclipse 以运行 JavaScript 文件:

  1. In Eclipse, got to Run > External Tools > External Tool Configurations

  2. Double click on Program to open a new configuration and name your new configuration (ex. Node_Config)

  3. 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)

    1. Mac:in the command line, run which node.
    2. Windows:in the command line, run where node, or see this for more/different windows advice
  4. Fill in the following:

    1. Working Directory: ${container_loc}
    2. Arguments: ${resource_name}
  5. Click apply, and then close.

  1. 在 Eclipse 中,转到运行 > 外部工具 > 外部工具配置

  2. 双击 Program 打开一个新配置并命名您的新配置(例如 Node_Config)

  3. 找出您安装了 node.js 的位置。将结果粘贴到 Eclipse 的“位置”框中。(如果您还没有安装节点,请在此处安装)

    1. Mac:在命令行中,运行which node.
    2. Windows:在命令行中,运行where node,或查看更多/不同的 Windows 建议
  4. 填写以下内容:

    1. 工作目录:${container_loc}
    2. 参数:${resource_name}
  5. 单击应用,然后关闭。

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,您可以做到这一点。我建议你

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

enter image description here

在此处输入图片说明

回答by Arpit Goyal

He is using WebStorm which is editor for Front-end dev from same company (JetBrains).

他正在使用 WebStorm,它是同一家公司 (JetBrains) 的前端开发编辑器。