Home
  • Intro
  •  
  • Energy
    • Energy diversion
    • My Energy Diverter
    • Oven control
    • Resources
  •  
  • Banana Pi M5
    • Install Armbian
    • Setting up
    • SSH connection
    • Static IP address
    • Install SAMBA
    • Install Apache
    • Install MySQL
    • Install PHP
    • Install phpMyAdmin
    • Install FTP server
    • Add web site
    • erase eMMC
  •  
  • Arduino
    • Programming
    • Connecting to PHP/MySQL
  •  
  • Energy app
    • Example
  •  
  • Music server (NAS)
    • miniDLNA
    • Installing on BPi-M5
    • Uploading files

Node.js and Yarn

To be able to send myself text alerts from the server, sensors off line, high temps, low temps..., through my 4G router, I needed to install Node.js and Yarn.

Node.js® is an open-source, cross-platform JavaScript runtime environment.

Yarn is a package manager for your code. It allows you to use and share (e.g. JavaScript) code.


Log in as root privileged su:
Just in case, update your system...

BPiM5:yourname:# apt-get update

BPiM5:yourname:# apt-get upgrade

Install Node.js. First you need to install a Global version. Later you will need to install a local variant in the directory of your code

BPiM5:yourname:# apt install nodejs

Step 1 - Installing Yarn Globally.
The easiest way is via "npm" which you may wish to install first ... then install Yarn

BPiM5:yourname:# apt install npm

BPiM5:yourname:# npm install -g yarn

You may wish to check the install using..

BPiM5:yourname:# yarn --version

(mine outputs version: 1.22.21)

The code for connecting to the modem requires an addition package, called " minimist ". Install minimist ...

BPiM5:yourname:# npm install minimist

Node.js, Yarn and minimist are now globally installed and .


Step 2 - Installing Yarn locally into your new project.
First create a directory for the project.. I created mine in the root of my website so it can easily be activated from local PHP code.
For this you can either use an FTP tool of Command Line Instructions (CLI). For CLI...
Change Directory to your website root.

BPiM5:yourname:# cd /var/www/html

Make a new directory. I called my project and folder " sendSMS ".

BPiM5:html:# mkdir sendSMS

Change directory into the newly form one.

BPiM5:sendSMS:# cd sendSMS

Initiate Yarn...

BPiM5:sendSMS:# yarn init

This will add a package.json configuration file and a yarn.lock file to your directory. The package.json contains configuration and your list of module dependencies. The yarn.lock file locks those dependencies to specific versions, making sure that the dependency tree is always consistent. To download and install all the dependencies in an existing Yarn-based project, use the install subcommand:

You will be asked ~8 (irrelevant) questions and pressing enter will just enter the default value, as show in the brackets. Change these if you wish.

BPiM5:sendSMS:# yarn install

To be able to FTP into the project directory, you much change ownership and accessability

BPiM5:sendSMS:# cd ..

BPiM5:html:# chown -R yourusername:yourusername sendSMS

BPiM5html:# chmod -R 755 sendSMS

Lastly, the Node.js file - sms-send.js - must have its accessabilty changed from 644 to 777 so to make it executable.

BPiM5:html:# cd sendSMS

BPiM5:sendSMS:# chmod -R 777 sms-send.js

Project " sendSMS " is now set up with a project-specific version of Yarn.

Next step: installing web hosting software - Apache Next