MISC-TN-013: Enabling node.js and electron.js for creating Javascript applications

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
DMI-Mito-top.png Applies to MITO 8M
Warning-icon.png This technical note was validated against specific versions of hardware and software. What is described here may not work with other versions. Warning-icon.png

History[edit | edit source]

Version Date Notes
1.0.0 July 2020 First public release

Introduction[edit | edit source]

Nowadays several designs are based on the latest Javascript technologies available for implementing advanced (Industrial) Graphical User Interface in an easy way.

Mito8M is the first DAVE Embedded Systems' product based on a core implementing the ARMv8-A architecture. Specifically, it is built upon the NXP i.MX8M system-on-chip (SoC).

Similarly to the Technical Note written for the SBC Axel platform using the AXEL Lite SOM, this Technical Note (TN) describes how to install the well known node.js runtime and the electron.js application framework.

Both node.js and electron.js allows to create desktop applications in JavaScript, HTML, and CSS.

Electron uses web pages as its GUI, so you could also see it as a minimal Chromium browser, controlled by JavaScript.

(rif. electron tutorial)

More information about electron can be found on its web site. It is useful to follow the Quick start guide and the complete documentation.

Testbed configuration[edit | edit source]

Due to the Mito8M electrical and mechanical compatibility with AXEL Lite, the testbed used for this TN is pretty similar to the one described here. Even though the SBCX carrier board is designed to host Axel Lite, in fact, it supports Mito8M as well.


Mito8M SoM on SBCX carrier board


For what concerns software, the following configuration was used:

  • Linux kernel: 4.14.78-mito-0.9.0
  • Yocto Sumo root file system

Installation[edit | edit source]

node.js[edit | edit source]

The node.js runtime environment can be easily installed using its Node Version Manager. The nvm package manager allows to install multiple node instances and manage them.

Installing node.js[edit | edit source]

Once nvm is installed, simply ask it for installing the latest LTS version of node.js:

root@imx8mmevk:~# nvm install --lts
Installing latest LTS version.
Downloading and installing node v12.18.2...
Downloading https://nodejs.org/dist/v12.18.2/node-v12.18.2-linux-arm64.tar.gz...
######################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v12.18.2 (npm v6.14.5)
Creating default alias: default -> lts/* (-> v12.18.2)
root@imx8mmevk:~#

electron.js[edit | edit source]

Then, using npm, it is possible to install the electron framework, just execute the following command:

root@imx8mmevk:~# npm install -g electron@6.1.5 --unsafe-perm=true
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/home/root/.nvm/versions/node/v12.18.2/bin/electron -> /home/root/.nvm/versions/node/v12.18.2/lib/node_modules/electron/cli.js

> electron@6.1.5 postinstall /home/root/.nvm/versions/node/v12.18.2/lib/node_modules/electron
> node install.js

Downloading tmp-4481-1-SHASUMS256.txt-6.1.5
[============================================>] 100.0% of 5.15 kB (5.15 kB/s)
[  186.578462] audit: type=1006 audit(1595331007.192:3): pid=4492 uid=0 old-auid=4294967295 auid=0 tty=(none) old-ses=4294967295 ses=2 res=1
+ electron@6.1.5
added 145 packages from 143 contributors in 109.345s
root@imx8mmevk:~#

package version[edit | edit source]

For checking the installed version, just execute the binaries like:

root@imx8mmevk:~# node --version
v12.18.2
root@imx8mmevk:~# electron --version --no-sandbox
v6.1.5
root@imx8mmevk:~# 

Demo[edit | edit source]

And finally get the electron framework running using:

/home/root/.nvm/versions/node/v12.18.2/bin/electron --no-sandbox https://www.electronjs.org/

and the web site is available on the screen:

electron running running on SBCX with Mito8M SOM and Full HD HDMI monitor