4

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

Arpit Goyal
  • 977
  • 11
  • 22
Olga
  • 89
  • 1
  • 1
  • 10

3 Answers3

7

To set up Eclipse to run JavaScript files:

  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.

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.

Community
  • 1
  • 1
ebbishop
  • 1,454
  • 1
  • 15
  • 30
  • I have node.js installed, but the command line gives Syntax Error when I try to run 'which node'. – Olga Jun 13 '16 at 11:24
  • I've pasted https://nodejs.org/en/ in Location box, but this config is still unavailable in Run menu options – Olga Jun 13 '16 at 11:25
  • it worked! I've put this C:\Program Files\nodejs\node.exe and it worked! thanks! – Olga Jun 13 '16 at 11:27
  • @Olga I'm so glad! Sorry about the `which node` command - that is mac specific command to find where you have node installed. I chould have asked what you are using. Would you mind marking this as answered? – ebbishop Jun 14 '16 at 17:51
5

Since Eclipse Neon you can do that. I suggets you that you

With Eclipse JEE Neon, you will benefit with Run As / Node.js Application and even with Debug As / Node.js Application:

enter image description here

Angelo
  • 1,987
  • 12
  • 17
0

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

Arpit Goyal
  • 977
  • 11
  • 22