Installing Server on a Raspberry Pi Zero W

LaserWeb information

  • Backend version: LaserWeb Comm Server 4.0.137

Problem description

I tried following the official instructions for installing the LaserWeb Comm Server on a Raspberry Pi at the following URL:

https://laserweb.yurl.ch/documentation/installation/36-install-raspberry-pi

The instructions for installing NPM did not work for me so I ended up installing NVM:

url -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

And installing the requisite version of NPM:

nvm install 10
nvm install-latest-npm

After that I had to manually install node-gyp, uri-js, and serialport. Once that was done, I successfully installed LaserWeb and when I run server.js everything appears to work:

pi@laserweb:~/lw.comm-server $ node server.js

***************************************************************
        ---- LaserWeb Comm Server 4.0.137 ----
***************************************************************
  Use  http://127.0.1.1:8000 to connect this server.

* Updates:
  Remember to check the commit log on
  https://github.com/LaserWeb/lw.comm-server/commits/master
  regularly, to know about updates and fixes, and then when ready
  update accordingly by running git pull

* Support:
  If you need help / support, come over to
  https://forum.makerforums.info/c/laserweb-cncweb/78
***************************************************************

The problem is that when I try to load the Web browser front end, all I get is a blank screen. If I open up the Developer tools Console in Chrome there’s a single error:

index.js:44675 Uncaught SyntaxError: Unexpected token '<<'

When I look at the referenced line number in the index.js file I see this:

<<<<<<< HEAD
/*!
  Copyright (c) 2018 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/react-select
*/
var stringifyValue = function stringifyValue(value) {
	return typeof value === 'string' ? value : value !== null && JSON.stringify(value) || '';
};
=======
  __REACT_HOT_LOADER__.register(selectPane, 'selectPane', 'C:/Users/cprez/Git/LaserWeb/LaserWeb4/src/actions/panes.js');
}();
>>>>>>> 28944f7 (Updated frontend app)

Google tells me that errors like this occur when a resource cannot be found. There are 34 more instances of errors like this in the index.js.

Does anyone know how to fix this?

I dug a little further and it seems the issue is in code commited to the repo itself:

So I had to rollback to a previous commit:

git checkout -- .
git checkout eb9da01
npm install -g node-gyp
npm install uri-js
npm install serialport
npm install
npm audit fix
node server.js

Server starts up:

pi@laserweb:~/lw.comm-server $ node server.js

***************************************************************
        ---- LaserWeb Comm Server 4.0.136 ----
***************************************************************
  Use  http://127.0.1.1:8000 to connect this server.

* Updates:
  Remember to check the commit log on
  https://github.com/LaserWeb/lw.comm-server/commits/master
  regularly, to know about updates and fixes, and then when ready
  update accordingly by running git pull

* Support:
  If you need help / support, come over to
  https://plus.google.com/communities/115879488566665599508
***************************************************************

And now it works:

image

I opened an issue in the Repo:

1 Like

If anyone is interested, this is the script I ended up with:

# Installing LaserWeb on a Pi Zero
# Modfied from: https://laserweb.yurl.ch/documentation/installation/36-install-raspberry-pi

# Start with a stock install of Rasbian Buster
# Add ssh and wpa_supplicant.conf files if you want it to boot headless.

# Update Tool, Set your hostname, Enable Serial, Set Timezone, Expand File System
sudo raspi-config

# Update everything
sudo apt update
sudo apt upgrade

# Install git
sudo apt install git

# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

# NVM requires log off/on, just reboot
sudo reboot

# Install Note.js and NPM, v10 is the last supported version for the Zero
nvm install 10
nvm install-latest-npm

# Start from home
cd /home/pi

# Clone the LaserWeb Git Repo
git clone https://github.com/LaserWeb/lw.comm-server.git
cd lw.comm-server

# Checkout a known working version
git checkout eb9da01

# Install node-gyp
npm install -g node-gyp

# Install URI-js
npm install uri-js

# Install serialport
npm install serialport

# Install LaserWeb
npm install

# Fix issues with node packages
npm audit fix

# Test run (CTRL+C to quit)
node server.js


# Setup to run as service...

# Start from the LaserWeb folder
cd /home/pi/lw.comm-server

# As a sanity check, verify the version of Node.js installed
node -v

# LaserWeb comes with a .service file for systemd, but it won't 
# work becuase we installed Node.js to a different location.
# Modify the .service file with the proper Node.js path.
sudo nano lw.comm-server.service

# Replace the ExecStart with the following, be sure to save.
# If the version number doesn't match above, adjust accordingly.
ExecStart=/home/pi/.nvm/versions/node/v10.24.1/bin/node /home/pi/lw.comm-server/server.js

# Create a symlink from the systemd folder to our .service file.
sudo ln -s `pwd`/lw.comm-server.service /etc/systemd/system

# Reload the service files so that system knows about this new one
sudo systemctl daemon-reload

# Start the service
sudo systemctl start lw.comm-server

# Verify the service is running
sudo systemctl status lw.comm-server

# Try to access the LaserWeb from a browser (http://<hostname>:8000)

# If you're happy, set the LaserWeb service to start on boot
sudo systemctl enable lw.comm-server.service

# To restart the service
sudo systemctl restart lw.comm-server

# To stop the service
sudo systemctl stop lw.comm-server
2 Likes

Thanks for the report. This was caused by an unfinshed git merge. This should be corrected with version 4.0.138.

1 Like

@cptskippy what distro - version were you installing on? there seems to be a package mismtch between bullseys lite and desktop.

I am getting stuck trying to follow your script . i have tried following the insrucitons on both a pi 0 W with bullseye lite from 5/31/211 and armbian 5.10.60. in both instances, its the nvm install 10 step that i get stuck on.

is there something that a newbie might overlook or be lacking in knowldege of pre-req’s that might affecdt nvm install 10 from executing ?

pi@laserweb:~ $ nvm install 10
Downloading and installing node v10.24.1...
Downloading https://nodejs.org/dist/v10.24.1/node-v10.24.1-linux-armv6l.tar.xz...
############################################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.24.1 (npm v6.14.12)
Creating default alias: default -> 10 (-> v10.24.1)
pi@laserweb:~ $ nvm install-latest-npm
Attempting to upgrade to the latest working version of npm...
* Installing latest `npm`; if this does not work on your node version, please report a bug!
git clone https://github.com/LaserWeb/lw.comm-server.gitgit clone https://github.com/LaserWeb/lw.comm-server.gitgit clone https://github.com/LaserWeb/lw.comm-server.gitgit clone h/home/pi/.nvm/versions/node/v10.24.1/bin/npm -> /home/pi/.nvm/versions/node/v10.24.1/lib/node_modules/npm/bin/npm-cli.js
/home/pi/.nvm/versions/node/v10.24.1/bin/npx -> /home/pi/.nvm/versions/node/v10.24.1/lib/node_modules/npm/bin/npx-cli.js
npm WARN notsup Unsupported engine for npm@8.3.0: wanted: {"node":"^12.13.0 || ^14.15.0 || >=16"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: npm@8.3.0

+ npm@8.3.0
added 67 packages from 17 contributors, removed 288 packages and updated 147 packages in 156.325s
* npm upgraded to: v
pi@laserweb:~ $




@Dennis_P, I apologize for not responding sooner, holidays and such.

The error is related to versioning in npm.

The intent of my instructions were to first installed the latest version of node for the rp0, which is 10. Then install the latest version of npm compatible with the node version installed. At least that’s what the nvm documentation says that command should do:

nvm install-latest-npm

Clearly that’s not the case because it’s trying to install the very latest version of npm. Looking at the npm versions, v8.0.0 was compatible with node 10, but v8.1.0 is not. At this point they’re up to version 8.3.1.

I think if you execute the following command it will install the compatible v8.0.0 version:

npm install -g npm@8.0.0

npm install -g npm@7.24.0

Let me know if that works.

* 2022-01-28 - Looks like 7.24.0 is the latest supported version.

The latest lw.comm-server version on the master branch is compatible with Node 12 → 16, grab it from Github.

I’ve tested installing on Buster and Bullseye; instructions are here:

This includes Instructions on installing Node12 on Buster (it’s the default on Bullseye), and then installing lw-comms-server.

  • There is no need to follow the second part of the instructions for downloading, installing and building LaserWeb4 itself. The current lw.comms-server version you get from master also includes the latest LW4 (and requires it, we have changed the server/client comms protocol version as part of upgrading the dependencies for node 12+)
  • It’s a bit light on how to then run the comm-server as a service, I need to worjk on that. The instructions on setting lw.comm-server as a service that are included in the main site still work.
1 Like

@easytarget, at the time I wrote this post, Node v10.21.0 was the latest supported version for Arm 6 which is what the Pi Zero and Zero W are based on. That’s why I’m explicitly specifying versions in my script.

The newer Raspberry Pis are based on Arm6/7 and have support up through the latest versions of Node.

Ah, sorry for any confusion @cptskippy
I do not believe that the current lw.comm-server will install and run under Node10 or earlier, though I’d be delighted to be proved wrong. However; supporting older Pi Zeros, even if the install is more complex, is very desirable and it is an ideal use-case for LaserWeb.

Unfortunately Arm6 support from Node10 on seems to be depreciated to ‘experimental’ status, there are still packages being produced, but no packaged installers for them from official sources.

There seems to be a reasonable discussion on StackOverflow about getting this going. It’s short and worth reading.

Which in turn leads here:

…which looks promising but I don’t have a Pi-Zero to test on.

If you have managed to get this going I’d be delighted to hear the results,