Skip to main content
This doc relates to the below revision of hardware
Mecha Logo

Comet (rev5)

For Pilot users

The all new Mecha Comet

Better in all ways, the next revision of Mecha Comet, coming soon.

Node.js

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It is commonly used for developing server-side applications, tools, and APIs. Node.js also includes npm, a package manager for JavaScript libraries.

Install Node.js

We will be using the NodeSource repository that provides up-to-date versions of Node.js. Launch terminal on your Comet or connect via SSH and run the following commands

  1. Add the NodeSource debian repository
# replace <version> with the desired version, e.g., 20.x)
$ curl -fsSL https://deb.nodesource.com/setup_<version>.x | sudo -E bash -

# Example for Nodejs 20.x
$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
  1. Now lets install nodejs from the repository.
$ sudo apt install -y nodejs
  1. After installation, verify that node and npm are properly installed, by running the commands below.
$ node --version
$ npm --version

Running an example

Let's build a simple "Hello, World!" app to test Node.js on the Comet.

1

Create a new directory, and a new source file for your go program.

$ mkdir hello_node && cd hello_node
$ nano main.js
2

Paste the following program in the editor

const main = () => {
console.log('Hello, Node.js!');
};
main();
3

Now lets compile and run the program.

$ node main.js
Hello, Node.js!

You are now ready to build and run Node.js based applications 🎉!