not working with simple js script from command line

Volumio Information

Volumio Version: 2.834
Hardware: Raspberry 4
DAC: None - using HDMI

I am trying to implement additional commands for an remote ir to select predefined webradio stations - basically following this discussion: IR Remote Controller Plugin and extra remote control.

However, I couldn’t get this to work. So I used a simple JS script to test communication with the socket api - this is more or less copied from WebSocket: Home Automation:

var io=require('');
var socket= io.connect('http://localhost:3000');
//Report successful connection
socket.on('connect', function () {
  console.log('Client Connected');
//Report disconnection
socket.on('disconnect', function () {
  console.log('Client Disconnected');
//Notify on player state changes, this includes volume changes, songs etc
socket.on('pushState', function (data) {
//Notify just the volume value
socket.on('pushState', function (data) {
//Set Volume to 15
socket.emit('volume', 15); 

Saved to disk and called in the command line:

cd /usr/local/bin/myscripts
node test.js

This starts without error but never terminates, no message displayed. Also no message in the system log.
npm install carried out sucessfully.
What am I doing wrong? Is there any authentication needed? Can’t I run the script simply from the command line?

Where are you running this script from? If you are running it from a different device, then you need to change the localhost to the devices host/address…

I logged into the device that runs volumio using ssh (kitty / putty from my Windows machine). The script is stored locally on the volumio device.
Tried both localhost and IPv4 addresses in the script - made not difference.

Did you get anywhere with this. I have a number of js scripts that I run but I have the same problem as you with a new flashed image. I have also tried going back to version 2.729 (the same as a working version I have) but still no joy. It seems that it is not connecting. I wonder if the ‘npm install’ is working as it used to…

At least I’ve got some success now :slight_smile:

Deleted package-lock.json and the complete node_modules from my own script folder and ran

npm install^1.7.4

This is how I got there:

sudo find / -name ""

From the result list I looked at /volumio/node_modules/

nano /volumio/node_modules/

CTRL+W ENTER shows the line with the version used in volumio:

 "_from": "^1.7.4"

My script now connects and displays some response. I added also

setTimeout(function() { socket.disconnect(); }, 500); 

at the end of the file - if that matters.

Many thanks, all working again.