Node.js on Khadas VIM


I would like to see some docs on how to use the GPIO pins. Maybe a simple example to toggle a digital pin on and off as well as accessing the value of an analog pin.


Topics for Khadas Docs

Hi, Ryanjgill:
Which OS do you run? Is it Android?


I was running the Ubuntu Mate. Looking forward to programming in Node.js


It seems that we need to port Node.js to Khadas VIM first :slight_smile:

Will research first, and update here.


I installed the latest version of Node on the Ubuntu Mate image. It was running great! I did a quick stress test on an Express web server and the results were pleasing :slight_smile:


Can you share the steps and guidance for your effort? A professional instructions is appreciated, and we will release it on Khadas Docs with the author name as you :wink:


Sure, I will recreate the steps starting from the latest Ubuntu image.

I think we only need to run the following 2 commands.

Install Node.js:

sudo apt-get install nodejs-legacy

Install NPM:

sudo apt-get install npm

Then we should be able to see each of the versions by doing node -v and npm -v


I am fond of nodejs, and i also wanted to install the latest version on the VIM (pro).
My installed firmware is Ubuntu 16.04 server, dated 11feb17.
I followed the instructions published here:

But I got stuck at some point.
Here are the commands I typed:

sudo apt-get install git
sudo apt-get install wget
sudo apt-get install build-essential libssl-dev
wget -qO- | bash -
nvm ls-remote

at this point, we are able to list all available nodejs version up to 7.7.3 as of today.
BUT this next command failed miserably:

nvm install 7.7.3

BECAUSE the function nvm_get_arch() in the file ~/.nvm/ is returning “aarch64” instead of “arm64” which is expected (see file list in

So I just modified nvm_get_arch() to return “arm64” exited my session, logged back in, then I was able to successfully run “nvm install 7.7.3”

last step to perform is:

nvm use 7.7.3

then “node --version” and “npm -v” were succesfull and we (hopefully) now can enjoy all the beauty of the latest nodejs functions on our beloved Khadas VIM;

Please try on your own and get back here to report about your success of failure.


Nice work ravelo. I was able to clone the latest version of nvm and it appears they have merged in a fix for the issue you were having.

I cloned the repo and then ran the install script.

git clone

cd nvm && bash

Confirmed successful install of Node v7.7.3 and NPM v4.2.1

Nice work guys! :heart_eyes:


NVM is totally awesome.

If you are feeling up for a treat, check out GVM.

Strong typing FTW ;).


i could have checked for and used the latest version of nvm on its github repo but i did not think of it,
now the fixed version does take into account aarch64, great!


and now, what about doing gpio from node anyone ?
is there a valid solution someone has found and used successfully?


@Terry has developed a demo APK on rooted Android Nougat ROM, he will release the demo source code after we release the new Android Nougat in this week.


apk are android java apps, my need is in fact some javascript linux apps which is able to do gpio, so, does @terry have such a code ?


Do you need the source code of GPIO on android ?
We will add the support for wiringpi in the future .


@terry, I like Android, but here I really need to be able to write an nodejs ubuntu app.
So source code for and android apk (java or c++) might not tell me anything at all on how to do the same under nodejs and ubuntu.

The very 1st step for me is be able to read / write on a GPIO pin from (ubuntu) shell script, please take that need into account.


You can follow below step to read / write the GPIO


1). You need to reconfigure the kvim_defconfig in kernel


2). The VIM GPIO port number list

	 GPIOH5:     176
	 GPIOH6:     177
	 GPIOH7:     178
	 GPIOH8:     179
	 GPIOH9:     180
    GPIOAO6:     151

3). Write / Read the GPIO

eg: config the GPIOH5 as high level output
echo  176 > /sys/class/gpio/export
echo  out  > /sys/class/gpio/gpio176/direction
echo  1    > /sys/class/gpio/gpio176/value

eg: config the GPIOH5 as input
echo  176 > /sys/class/gpio/export
echo  in  > /sys/class/gpio/gpio176/direction

Add Bluetooth Support for Ubuntu
MPI over GPIO and Clustering

oh yeah !!! this is first class info and this really begins to be usefull !
I’ll test very soon and will report here


when you modify kvim_devconfig , you need to recompile and install the new kernel, right ?
if you have already done so, could you please publish the modified kernel and tell us how to deploy it on a “khadas” ubuntu server installed on emmc?
thks !


Support for wiringpi would be game changer for gpio. I look forward to this :+1: