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