Raspi not a constructor

I was trying to connect my raspberry pi to Losant, following the Losant documentation to a T, however I keep receiving an error that says “Raspi is not a constructor”.

This is the link that I was using and following to connect my raspberry pi.

Hi @Hector_Duran. Welcome to the Losant Forums.

I’m working on confirming this right now by running the repo on a Pi, but based on this topic on your error, I think the solution will be to do the following …

After cloning the repo, in the index.js file, change the line …

var raspi = require('raspi-io');

… to …

var raspi = require('raspi-io').RaspiIO;

I’ll let you know once I’ve confirmed or if if the issue is elsewhere. And I’ll make sure to update that repo with the fix.


@Hector_Duran that seems to be the issue.

Thank you very much, I changed what you suggested yet I am now getting an error that reads:
Error: EACCES: permission denied
and later says

Sounds like a classic Linux permission issue -

Are you running the command with sudo? Per raspi-io’s documentation -

Warning: this module must be run as root, even though it cannot be installed as root.

That being the case, try running with this command and see if that gets you past it -

sudo node index.js