Skip to content
Tino Desjardins edited this page Aug 10, 2018 · 64 revisions

Getting Started

This page explains how to install and configure Tern IDE. This Eclipse plugin is based on the powerful JavaScript inference engine tern.js which is written in JavaScript.

You can see the online tern demo which uses tern in Web Browser with CodeMirror.

To use this engine on Java context, tern.java is used. It executes tern.js with node.js. That's why you will see that, you must install node.js server or use an embedded node.js.

tern.js is able to manage any JavaScript framework by developping a tern plugin (see Tern modules to know list of tern plugin). For instance, here a screenshot with a jQuery completion :

jQuery completion

If you want to use :

Installation

Tern IDE is developped/tested with Eclipse 4.5 (Mars). It is advised to use this Eclipse version (even if Tern IDE could work with older version of Eclipse).

To install Tern IDE, please read Installation - Update Site section.

When you will use Tern IDE update site you will see that:

Update site

You must select:

  • Tern - Embed Node.js if you have not node.js installed on your computer. Node.js is required to execute tern.js.
  • Tern IDE to use tern with Eclipse IDE.
  • Tern - Tooling if you want to generate tern plugin, JSON Type Definition or Web Browser editor (CodeMirror, Ace, Orion) with tern. For more information please read Tern Toolings

Tern Configuration

Now you must convert your project to Tern Project :

Convert To Tern Project

Preferences Settings

This section explains how to configure tern to use a JavaScript framework.

Global Preferences

This section is about "global preferences" dialog that you open with Window/Preferences.

Node.js

Tern IDE is based on the JavaScript inference engine tern.js which is written in JavaScript. To use it, tern is executed with node.js (Rhino is too slow for that). You must configure node.js. To do that you can :

  • use your installed node.js. For that, you must select the "Native node" install type and select the well node file :

Native Node

when the native node is selected, it searches node binary in default folders installation (ex : "C:\Program Files\nodejs\node.exe" for Windows) and if it doesn't find, it searches in your node in your "PATH" environment.

If you wish to download and install node.js, it's important to restart your computer before using Tern IDE in order to your OS update correctly your "PATH" environment with your installed node.js.

  • use an embed node. For that you must install the well embed node.js according your OS :

Embed Node

Project preferences

This section is about "project properties" dialog which is available if you select your project and use "Properties" menu item of the contextual menu (or Alt/Enter).

Tern Modules

Tern module is a Tern Plugin or JSON Type definition.

Here a list of available tern modules :

You can select a tern module by clicking on the Tern / Modules item :

Tern Modules

Scripts path

When tern is used for completion, validation, hover, hyperlink, it must load before (just the first time) a list of your JavaScript. To do that you must configure your script paths by selecting your js folder which contains your JavaScripts (it's the same thing than for Java build path) :

Script paths

For more information, please read Tern Script Path

Validator

Tern IDE provides several linter like ESLint, JSHint. Please read Tern Linter section for more information.

Let's go!

At this step we have finished to configure Tern IDE Eclipse, now it's time to check that everything works (tern with node.js is well configured).

JavaScript Editor

Open a JavaScript editor, fill it with :

var arr = ["a", "b"];
arr.

and try to open completion after dot of arr variable. It must show completion items for array :

Array Completion

This feature is managed by tern, if it doesn't work, see Troubleshooting section.

Troubleshooting

If you have checked your configuration and completion doesn't work for HTML and JavaScript editor, it means that there is a problem with tern with node.js. To verify that you can see errors with :

  • Error log view.
  • Tern console

Error log view

TernErrorLog

Tern console

You can trace the start of node.js server and the request/response of the tern server by using the Eclipse console.

To do that, you must active the tern console for your project:

TernConsoleProjectProperties

If you retry to execute completion for instance to use tern server, you will see the node.js command and the error in the console:

TernConsoleError

When you will have not problem, you can see the JSON request/response of the tern server when it is use it:

TernConsoleOK

See Tern Console for more information.

If you have again, problem, please create an issue here.

Clone this wiki locally