Node 6 on RPi - Raspbian Stretch

I’ve been banging my head against the wall trying to get LaserWeb setup on an RPi 3, and I failed at the first hurdle - installing Node!

If you follow the instructions for installing to Raspberry Pi, on Raspbian Stretch, npm doesn’t get installed - and if you then try to install it through apt, the version that gets installed is 1.something - far too low for LaserWeb to use.

I’ve found a workaround - this replaces the first section in the guide (" Install Node 6.x"):

wget -O - https://raw.githubusercontent.com/audstanley/NodeJs-Raspberry-Pi/master/Install-Node.sh | sudo bash

This will initially install the latest version of Node, but we can install our preferred version by then running:

sudo node-install -v 6.17.1

This will install the versions that we need, including npm. This is what versions get installed:

node -v
v6.17.1
npm -v
3.10.10

The only other issue I found was with the config.js file - I needed to change the first line, changing .load into .config instead (this is an issue with the new dotenv library, not directly related to the node version)

So now I have a happily running Raspberry Pi running lw-comm-server fine, and hopefully this will help others trying to do the same.

Please try it with node 10, according to the folowing wiki:


This has the advantage of the new Serialport Library 6.2.2 which is faster and causes less problems.

Cool, I’ll give that a go. I didn’t realise that the guide on the git was more up-to-date than the guide on the main website.

Me to. Now I removed the instructions on the LW4 git wiki and added a link to the lw.comm-server wiki instead.

Hi! My first comment on this forum :slight_smile:

Just wanted to give an alternative solution as I was struggling the same on my Raspberry Pi today.

I am using a Raspberry Pi 2 and followed the instructions on the Github Wiki. However I installed the latest version of Node (12.4) which went perfectly fine. The only thing that didn’t work was - as noted by others - the compilation of the SerialPort library. To make that work, I changed the version of the SerialPort library to 7.1.5 (latest) in the package.json file and then rerun npm install. After that, all worked perfectly well!

The problem is that a release of a third party library like SerialPort is made for a specific Node version (or a minimum). As soon as this version dependency isn’t there any longer, issues will appear.

To overcome this, software projects must define which version of third party libraries they use/support and have this locked down. For Node this can be done by providing the npm .lock file with the source code. Node will then use the provided lock file rather than pulling the latest versions of each dependency.

Hope this can help anybody :slight_smile:

Cheers! Sacha

1 Like

The versions of all dependencies are already defined in the package.json file (versions can be fixed to a specific major version). It’s just not managed perfectly :wink:

PS: I recomend to stay with the LTS version 10 of node js.

1 Like

You are correct, however the combination of Node 10 and SerialPort 6.2.2 is not defined. There is an option you can set in the package.json to specify the required Node version: “engines”. For example { "engines" : { "node" : ">=0.12" } }

Just wanted to let others know they can use Node 12 but need to use SerialPort version 7.1.5 :slight_smile:

I just don’t want to recomend versions that we (the devs) never tested to users that are not pros, because we can not support them.

Understood. Using the ‘engines’ option you can ensure only the supported versions are used. (If you like) :slight_smile:

Thanks for the hint. I will check the engines and dependencies when I get some time.

1 Like