JavaScript User Guide
Node.js user guide
Install Node.js with apt
sudo apt-get update
sudo apt-get install -y nodejs npm
Verify Node.js installation.
$ node -v
v18.13.0
$ npm -v
9.2.0
The default version of Node.js in Bianbu source is v18.13.0. Specific version has to be installed with NVM.
Install specific version of Node.js with NVM
Install NVM
Download and run shell script according to https://github.com/nvm-sh/nvm
, please replace the latest NVM version number based on the repository.
With curl:
sudo apt install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
or with wget:
sudo apt install wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Verify NVM installation.
$ nvm -v
0.40.1
Install Node.js
The official build of node has not been adapted for RISC-V which causes errors. Insteadly, we download adapted Node.js form unofficial-builds. For more, please refer to https://github.com/nodejs/unofficial-builds/
.
NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release nvm install 20.16.0
Verify Node.js installation.
$ node -v
v20.16.0
Example
clumsy-bird
Clone project.
git clone https://github.com/ellisonleao/clumsy-bird
Install dependencies.
cd clumsy-bird
npm install
sudo apt install grunt
Run service.
grunt connect
You can see the following output. The service is deployed at http://0.0.0.0:8001
. Open this URL in your browser to start.
$ grunt connect
Running "connect:root" (connect) task
Waiting forever...
Started connect web server on http://0.0.0.0:8001
Electron user guide
Prepare
Please install Node.js first.
Quick start
Clone electron-quick-start,
git clone https://github.com/electron/electron-quick-start.git ~/electron-quick-start
Install RISC-V adapted Electron from SpacemiT with npm.
cd ~/electron-quick-start
ELECTRON_MIRROR=http://archive.spacemit.com/electron/ electron_use_remote_checksums=1 npm install electron@29.3.1
Start demo.
npm start
Seeing the following screen indicates success.

Electron-builder user guide
Electron-builder is a complete solution to package and build a ready for distribution Electron Native app for macOS, Windows and Linux with "auto update" support. The official electron-builder and related components have not been adapted to RISC-V. Therefore, we use RISC-V adapted electron-builder from SpacemiT. Electron-quick-start is the project to be packaged.
Prepare
Please install Node.js first.
Clone project
git clone https://github.com/electron/electron-quick-start.git
cd electron-quick-start
Configure package.json
vim package.json
Add package commands under "scripts", we use RISC-V adapted Electron from SpacemiT here.
"scripts": {
"pack-dir": "ELECTRON_MIRROR=http://archive.spacemit.com/electron/ electron-builder --linux --dir",
"pack-tgz": "ELECTRON_MIRROR=http://archive.spacemit.com/electron/ electron-builder --linux tar.gz"
}
Add packaging configurations.
"build": {
"productName": "demo",
"directories": {
"output": "build"
},
"linux": {
"category": "Utility"
}
},
Add development dependencies. Please indicate source repository with @repository_name/package_name. The following @electron
is SpacemiT Node.js package repository.
"devDependencies": {
"electron": "29.3.1",
"@electron/electron-builder": "25.0.0-alpha.5"
}
Finally, your package.json should be like:
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"pack-dir": "ELECTRON_MIRROR=http://archive.spacemit.com/electron/ electron-builder --linux --dir",
"pack-tgz": "ELECTRON_MIRROR=http://archive.spacemit.com/electron/ electron-builder --linux tar.gz"
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"build": {
"productName": "demo",
"directories": {
"output": "build"
},
"linux": {
"category": "Utility"
}
},
"devDependencies": {
"electron": "29.3.1",
"@electron/electron-builder": "25.0.0-alpha.5"
}
}
Set repository URL
npm config set @electron:registry https://git.spacemit.com/api/v4/projects/36/packages/npm/
Install dependencies
We set ELECTRON_MIRROR
for RISC-V adapted Electron. Do not set mirror URL of Electron and electron-builder with npm config
, otherwise the mirror URL specified by the command line will be invalid. Check by npm config list
.
ELECTRON_MIRROR=http://archive.spacemit.com/electron/ electron_use_remote_checksums=1 npm install
Start packaging
Distribute in dir
npm run pack-dir
This command makes folder linux-riscv64-unpacked
in output dir build
.
bianbu@k1:~/electron-quick-start$ tree build/linux-riscv64-unpacked/ -L 1
build/linux-riscv64-unpacked/
├── chrome_100_percent.pak
├── chrome_200_percent.pak