Isaac Su / 2020.06.21

How to get mastodon-streaming working with nvm

This error started coming up when trying to start the mastodon-streaming service via systemctl.

Error: Cannot find module '../dist/bindings/cws_linux_57' check './node_modules/@clusterws/cws/build_log.txt' for post install build logs

This began after I upgraded to Mastodon 3.1.4 and started using nvm to manage my node versions.

Turns out, nvm adds a little complication to the usual npm run start that is used to start mastodon-streaming.

Here's what I had to do:

1. Create an nvm wrapper shell script

I called mine ~/live/mastodon-streaming-start.sh

#!/bin/bash
\. /home/mastodon/.nvm/nvm.sh
npm start

2. Make it executable

chmod +x mastodon-streaming-start.sh

3. Update the mastodon-streaming.service definition

Mine was in /etc/systemd/system/mastodon-streaming.service

Change the following line:

ExecStart=/usr/bin/npm run start

to:

ExecStart=/home/mastodon/live/mastodon-streaming-start.sh

4. Reload the service

systemctl daemon reload
systemctl restart mastodon-streaming

systemctl status mastodon-streaming # to check that it's started

That should do it.