# ReferenceError: Buffer is not defined

**URL:** <https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543>\
**Category:** Questions & Help\
**Tags:** homeyscript\
**Created:** [June 9, 2022, 7:54pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543 "2022-06-09T19:54:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sen-Sai](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sen-sai/32/13164_2.png) [@Sen-Sai](https://community.homey.app/u/Sen-Sai)\
**Post date:** [June 9, 2022, 7:54pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/1 "2022-06-09T19:54:36Z")

</div>

As off today, a script that has always worked, now suddenly throws an error …  
❌ Script Error

⚠ ReferenceError: Buffer is not defined  
at connectToWallbox (wallbox.js:25:35)  
at wallbox.js:131:19  
at processTicksAndRejections (node:internal/process/task\_queues:96:5)

I am running Homey 7.4.1 and HomeyScript v3.3.0.  
Restarted HomeyScript and also have restarted Homey. No change.  
No other installs etc done.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [June 9, 2022, 8:48pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/2 "2022-06-09T20:48:34Z")

</div>

I think it helps when you share the script with us?

---

<div class="post-metadata">

**Author:** ![Sen-Sai](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sen-sai/32/13164_2.png) [@Sen-Sai](https://community.homey.app/u/Sen-Sai)\
**Post date:** [June 9, 2022, 9:26pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/3 "2022-06-09T21:26:31Z")

</div>

I don’t see why. Buffer is a global variable set by homeyscript. Now it is not defined anymore. Why do you need the script?  
If you think it’might help, but I don’t see how : [Wallbox Pulsar plus charger lock/unlock pause/resume](https://community.homey.app/t/wallbox-pulsar-plus-charger-lock-unlock-pause-resume/54616)

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [June 9, 2022, 9:53pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/4 "2022-06-09T21:53:14Z")

</div>

I’m not sure how your script ever worked because nothing has been updated that could cause your issue as far as I can see. However you can update your script to at least work again with this:

```auto
const Buffer = this.constructor.constructor("return Buffer")()
console.log(Buffer.from('test'));

```

---

<div class="post-metadata">

**Author:** ![Sen-Sai](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sen-sai/32/13164_2.png) [@Sen-Sai](https://community.homey.app/u/Sen-Sai)\
**Post date:** [June 9, 2022, 10:13pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/5 "2022-06-09T22:13:40Z")

</div>

I disagree:  
3.2.6  
14 okt. 2021  
Added `Buffer` to global scope.

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [June 9, 2022, 10:35pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/6 "2022-06-09T22:35:07Z")

</div>

You are right I could not see this in the source. I think there has been a publish of the app without the source being saved. Meaning the next version does not have the Buffer change with it.

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [June 9, 2022, 10:48pm UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/7 "2022-06-09T22:48:10Z")

</div>

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/7/177b44ca77cbca844339f3950cd67c3b12f61c3f.png)

---

<div class="post-metadata">

**Author:** ![Sen-Sai](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sen-sai/32/13164_2.png) [@Sen-Sai](https://community.homey.app/u/Sen-Sai)\
**Post date:** [June 10, 2022, 5:57am UTC](https://community.homey.app/t/referenceerror-buffer-is-not-defined/64543/8 "2022-06-10T05:57:10Z")

</div>

That was quick! Buffer is back, thanks!
