Recent Changes - Search:

Home Page


Main

Downloads
Windows
macOS
Linux (via apt / rpm )
Linux wxWidgets
Release Notes

Wiki
Documentation
FAQ

Build CodeLite
Linux
Windows
macOS

Devs
Debug CodeLite Linux
Building Clang
Build wxWidgets (MSW)
Coding Guidelines
Create a Plugin

Nodejs

Download Latest CodeLite from here

General


Node.jsĀ® is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. With Recent builds of CodeLite, it is possible to create, run and debug Node.js applications.

In short, Node.js is server side JavaScript engine

Node.js Workspace


To fully maximize CodeLite's JavaScript capabilities, you first need to create a workspace. A Node.js workspace is simply a folder with a single JSON file .workspace which contains some metadata information about the workspace.

You can create a workspace for an existing source files or create a new workspace.

Create a new workspace

  • From the main menu, click on the New Workspace
  • CodeLite will pop a dialog suggesting the workspace type, select Node.js
  • In the next dialog, you will be requested to fill the workspace path and the workspace name
    • Optionally, you can check the option to create the workspace in a new folder
  • Click OK and you should be seeing your new workplace in the Workspace tab (see screenshots below)

Create a workspace from an existing source files

You can create a workspace from an existing source files by following the previous section with minor changes:

  • Set the workspace path to the folder containing your source files
  • Uncheck the option: Create in a new folder

Another option (simpler): Open your file browser (Windows Explorer, Finder, Dolphin etc), drag the folder that contain your sources and drop it on the Workspace tab

Writing Hello World


Now that we have created a workspace, its time to create a simple Hello World JS application

  • Right click on the root folder and select New File and give it a name hello.js
  • Copy / paste the below code:
function printHelloWorld() {
    console.log("Hello World");
}

printHelloWorld();

Note that CodeLite offers an excellent Java Script code completion based on the tern project

  • Execute your code by clicking Ctrl-F5 or from the menu Build->Run
  • CodeLite will popup the execution dialog for Node.js and will request the path Node.js executable + script to run (CodeLite will provide a sensible defaults)
    • This dialog also allows you to pass command line arguments to Node.js
  • Click OK

Use Ctrl-` to toggle the output view

Debugging our Hello World sample


Debugging a Node.js application is quite straightforward. By default, CodeLite will execute Node.js with the --debug-brk flag, which means: stop on first line To start a debug session:

  • Click F5
  • CodeLite will once again will popup the execution dialog for Node.js, this time the port field is enabled. Same as before, fill the paths and click OK
  • The Debug perspective is loaded (CodeLite will also show the toolbar if it is hidden)

You can now use the following keyboard shortcuts (or use the toolbar):

  • F10 - next line
  • F11 - step into function
  • Shift-F11 - step out of the current function
  • F5 - resume execution ("continue") until next breakpoint is hit
  • F9 - toggle breakpoint
  • Shift-F5 - stop debugging
  • Ctrl-CLICK (OSX: CMD-CLICK)- display tooltip for the word / selection under the mouse pointer

Showing tooltip

Edit - History - Print - Recent Changes - Search
Page last modified on December 09, 2018, at 02:47 PM