Start Script at Boot Up on Raspberry Pi

Guides
https://gauntface.com/blog/2015/12/02/start-up-scripts-for-raspbian

http://www.diegoacuna.me/how-to-run-a-script-as-a-service-in-raspberry-pi-raspbian-jessie/

If you are going to use a network service you may want need to change the [Unit] directives to look something like the NGinx service. See this article for details on how a network service works: https://medium.com/@johannes_gehrs/getting-started-with-systemd-on-debian-jessie-e024758ca63d.

Notice the service is only started After the network.target (After=network.target) event is completed. This is the important distinction.

[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=/usr/sbin/nginx -s quit
[Install]
WantedBy=multi-user.target

Install Node.js on Raspberry Pi

Recommended Method

Use these scripts made by
https://github.com/sdesalas/node-pi-zero

Using Direct Download and Auto Start on Boot
http://weworkweplay.com/play/raspberry-pi-nodejs/

 

Manual Method

*Not recommended due to inability to upgrade version easily.

At the time of this post the latest version that offers a binary tarbal for ARMv6 hardware is v6.11.3.

https://nodejs.org/dist/v6.11.3/node-v6.11.3-linux-armv6l.tar.gz

Alternate versions that my support AMRv6 hardware will be available here: https://nodejs.org/en/download/releases/

Steps to get it this version installed

wget https://nodejs.org/dist/v6.11.3/node-v6.11.3-linux-armv6l.tar.gz
tar -xvf node-v6.11.3-linux-armv6l.tar.gz 
cd node-v6.11.3-linux-armv6l/
sudo cp -R * /usr/local/
command node -v
v6.11.3

 

Notes:

Node.js downloads from the version repository
https://nodejs.org/en/download/releases/

https://nodejs.org/dist/

Using package manager you will get an error as displayed below
https://nodejs.org/en/download/package-manager/

## You appear to be running on ARMv6 hardware. Unfortunately this is not currently supported by the NodeSource Linux distributions. Please use the ‘linux-armv6l’ binary tarballs available directly from nodejs.org for Node.js v4 and later.

Using a manual method
https://blog.wia.io/installing-node-js-v4-0-0-on-a-raspberry-pi