# Raspi not a constructor

**URL:** <https://forums.losant.com/t/raspi-not-a-constructor/3710>\
**Category:** Help\
**Tags:** mqtt\
**Created:** [April 2, 2021, 4:44pm UTC](https://forums.losant.com/t/raspi-not-a-constructor/3710 "2021-04-02T16:44:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hector\_Duran](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hector\_Duran](https://forums.losant.com/u/Hector_Duran)\
**Post date:** [April 2, 2021, 4:44pm UTC](https://forums.losant.com/t/raspi-not-a-constructor/3710/1 "2021-04-02T16:44:29Z")

</div>

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”.

> **[How To Access Your Raspberry Pi's GPIO Over the Internet](https://www.losant.com/blog/how-to-access-your-raspberry-pis-gpio-over-the-internet)**
>
> A tutorial on how to get started with the Raspberry Pi and Losant.

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

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [April 2, 2021, 5:57pm UTC](https://forums.losant.com/t/raspi-not-a-constructor/3710/3 "2021-04-02T17:57:03Z")

</div>

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](https://www.gitmemory.com/issue/nebrius/raspi-io/118/499357844), I think the solution will be to do the following …

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

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

```

… to …

```auto
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.

Thanks,  
Dylan

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [April 2, 2021, 7:10pm UTC](https://forums.losant.com/t/raspi-not-a-constructor/3710/4 "2021-04-02T19:10:27Z")

</div>

@Hector_Duran that seems to be the issue.

---

<div class="post-metadata">

**Author:** ![Hector\_Duran](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hector\_Duran](https://forums.losant.com/u/Hector_Duran)\
**Post date:** [April 2, 2021, 8:45pm UTC](https://forums.losant.com/t/raspi-not-a-constructor/3710/6 "2021-04-02T20:45:40Z")

</div>

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  
errno:-13

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [April 2, 2021, 8:54pm UTC](https://forums.losant.com/t/raspi-not-a-constructor/3710/8 "2021-04-02T20:54:10Z")

</div>

Sounds like a classic Linux permission issue -

> <https://stackoverflow.com/questions/48910876/error-eacces-permission-denied-access-usr-local-lib-node-modules>

Are you running the command with `sudo`? Per [raspi-io’s documentation](https://www.npmjs.com/package/raspi-io) -

> **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 -

```auto
sudo node index.js

```
