Installing and Using NodeJS

NodeJS is a scripting language that uses a JavaScript runtime, essentially, it is Javascript you can run without using a browser. It’s incredibly easy to make powerful and complex applications. NodeJS takes advantage of a large amount of open-source modules developed by the community in order to further simplify your work.

Note: Any Omega2 running firmware v0.3.0 or greater supports NodeJS v8.10.0.

Installing NodeJS

Installing NodeJS will take about 5.7 MB of space on the Omega, so make sure you’ve got enough space before continuing.

Connect to the Omega’s terminal using either SSH or Serial.

Run the following commands on the terminal:

opkg update
opkg install node

npm

npm stands for Node Package Manager. As the name implies, it’s the official way of installing and updating node packages. Node is usable on its own, but npm gives you access to a whole new world of software others have built - so you don’t need to do it yourself!

Installing npm

The commands and procedure is much the same as installing NodeJS:

Using npm

SPECIAL NOTE! This is different than on a computer!

To install packages with NPM, there’s a specific syntax that needs to be used. Instead of:

npm install <PACKAGE>

use

node --max_old_space_size=64 $(which npm) install <PACKAGE>

Not only can npm install packages, it can also create a package out of your project! To do so, run the command below, it will guide you through the creation of your own node package.

If you have packages installed already, they will be included as dependencies, and your package.json will be updated accordingly.

Going further

We’ve included links to guides on how you can use NodeJS on the Omega to create fantastic projects.

Learning NodeJS

NodeJS Documentation is available from the official Node website.

Visual Programming with Node-Red

Node-RED is a flow-based, visual programming tool based on NodeJS that runs in the browser. It comes packaged as an OnionOS App for the Omega2 Pro and can be easily accessed through OnionOS in any browser.

Learn more about installing and using Node-Red on the Omega2 Pro.