Troubleshooting

SyntaxError: Unexpected token '??=' 

This error occurs on Node.js 14. Saltcorn now requires Node 16+

Upgrade fails with an error code

Log in with SSH and do an upgrade. Make sure you are the user running saltcorn (often this user is called saltcorn). Then run

npm install -g @saltcorn/cli@latest --unsafe

Directory not empty error during upgrade

The error shown is: 

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/saltcorn/.local/lib/node_modules/@saltcorn/cli
npm ERR! dest /home/saltcorn/.local/lib/node_modules/@saltcorn/.cli-CWg9jX9y
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/saltcorn/.local/lib/node_modules/@saltcorn/cli' -> '/home/saltcorn/.local/lib/node_modules/@saltcorn/.cli-CWg9jX9y'

npm ERR! A complete log of this run can be found in: /home/saltcorn/.npm/_logs/2023-11-28T08_22_27_136Z-debug-0.log
 

Delete your node_modules directory (rm -rf /home/saltcorn/.local/lib/node_modules), then install again with

npm install -g @saltcorn/cli@latest --unsafe

If you are on a 1G or less machine, you may now run out of memory because you were doing a larger install off more modules. Follow the directions below and try again if you run out of memory.

Upgrade is Killed

If you try an upgrade, and it says "Killed", you are out of memory. For instance  

saltcorn@saltcorn082onubuntu2204-s-1vcpu-1gb-syd1-01:~$ npm install -g @saltcorn/cli@latest --unsafe

(#########⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠇ reify:fsevents: sill reify mark deleted [

Killed

Then you are out of memory. Free up some memory by stopping Saltcorn (as root, run systemctl stop saltcorn, then when done systemctl start saltcorn) or create a swap file by following these directions:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04

Does not restart after upgrade or reboot

Check your logs (run as root: journalctl -u saltcorn -f). If you see

Error: bind EACCES 0.0.0.0:80

EACCES: '0.0.0.0:80'

that means the saltcorn unit cannot open port 80. There are two possible reasons:

1) Something else is already running on port 80. perhaps you started saltcorn on the command line. Stop the systemd unit (systemctl stop saltcorn) and then try to run ps aux | grep saltcorn and kill any processes. Retart your systemd unit (systemctl start saltcorn)

2) the node binary was updated by the operating system and lost its ability to open port 80 without superuser privileges. You need to run as root

setcap 'cap_net_bind_service=+ep' `which node`

to give the new updated node executable the right to open port 80 (until it is upgraded again); or these two commands

echo 'net.ipv4.ip_unprivileged_port_start=80' >> /etc/sysctl.conf
sysctl --system

To permanently allow non-root users to open port 80.

Then restart the systemd unit with 

systemd restart saltcorn