# Script report a referenceError

**URL:** <https://community.grafana.com/t/script-report-a-referenceerror/99380>\
**Category:** OSS Support\
**Created:** [January 14, 2021, 9:06am UTC](https://community.grafana.com/t/script-report-a-referenceerror/99380 "2021-01-14T09:06:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobobkb](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bobobkb](https://community.grafana.com/u/bobobkb)\
**Post date:** [January 14, 2021, 9:06am UTC](https://community.grafana.com/t/script-report-a-referenceerror/99380/1 "2021-01-14T09:06:31Z")

</div>

hi erveryone!

I run my script and report an error！

this is my script

test.js

```auto
import grpc from "k6/net/grpc";
import { check } from 'k6';

export let options = {
  scenarios: {
    contacts: {
      executor: 'per-vu-iterations',
      vus: 1,
      iterations: 1,
      maxDuration: '1s',
    },
  },
};

export default () => {  
  console.log(Buffer.from("Hello World").toString('base64'));
}

```

i run `k6 run test.js`

and then report  
`ERRO[0000] ReferenceError: Buffer is not defined`

---

<div class="post-metadata">

**Author:** ![mstoykov](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/mstoykov/32/35309_2.png) [@mstoykov](https://community.grafana.com/u/mstoykov)\
**Post date:** [January 14, 2021, 12:05pm UTC](https://community.grafana.com/t/script-report-a-referenceerror/99380/2 "2021-01-14T12:05:54Z")

</div>

Hi @bobobkb, welcome to the community forum 🎊

As the message points out `Buffer` is not defined, as it is a nodejs thing and k6 isn’t nodejs or based on it. I guess what you want is to base64encode stuff, in which case you can use the [encoding](https://mdr-ci.staging.k6.io/docs/refs/pull/144/merge/javascript-api/k6-encoding) package.

It does have some [problems](https://github.com/loadimpact/k6/issues/1798) that you might run into, but they seem to be only with binary data, so hopefully, you won’t be affected 🙂

edit: You can also see how to use ArrayBuffer to do the same [here](https://community.grafana.com/t/base64-encode-arraybuffer/99148/2), although that isn’t needed if you have a string as the original form

---

<div class="post-metadata">

**Author:** ![nedyalko](https://avatars.discourse-cdn.com/v4/letter/n/d26b3c/32.png) [@nedyalko](https://community.grafana.com/u/nedyalko)\
**Post date:** [January 14, 2021, 12:25pm UTC](https://community.grafana.com/t/script-report-a-referenceerror/99380/3 "2021-01-14T12:25:58Z")

</div>

If you just need base64, then the `k6/encoding` package is better. But for a generic substitute of the NodeJS-specific `Buffer`, you probably should use `ArrayBuffer`: [ArrayBuffer - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)

---

<div class="post-metadata">

**Author:** ![bobobkb](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@bobobkb](https://community.grafana.com/u/bobobkb)\
**Post date:** [January 15, 2021, 1:58am UTC](https://community.grafana.com/t/script-report-a-referenceerror/99380/4 "2021-01-15T01:58:28Z")

</div>

it works for me,thinks
