# SimplexNoise is not defined

**URL:** https://discourse.processing.org/t/simplexnoise-is-not-defined/33163
**Category:** Libraries
**Created:** [October 29, 2021, 4:22pm UTC](https://discourse.processing.org/t/simplexnoise-is-not-defined/33163 "2021-10-29T16:22:12Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [October 30, 2021, 8:51am UTC](https://discourse.processing.org/t/simplexnoise-is-not-defined/33163/5 "2021-10-30T08:51:35Z")

</div>

> [@momo](#):
>
> , I must did something wrong.

No worries, you didn’t. After a closer look I’ve spotted the library fails at the very start:  
`Object.defineProperty(exports, "__esModule", { value: true });`

There’s no existing _exports_ in the browser’s JS environment.

But rather _exports_ exists for code running in the Node.js server-side environment.

That is, the library Simplex-Noise is primarily meant for server-side apps, not client-side browsers.

However not all is lost: Besides the CommonJS (cjs) version:  
[cdn.JsDelivr.net/npm/simplex-noise/dist/cjs/simplex-noise.js](http://cdn.JsDelivr.net/npm/simplex-noise/dist/cjs/simplex-noise.js)

There’s also an EcmaScript Module (esm) version:  
[cdn.JsDelivr.net/npm/simplex-noise/dist/esm/simplex-noise.js](http://cdn.JsDelivr.net/npm/simplex-noise/dist/esm/simplex-noise.js)

But b/c a module JS file has a different behavior compared to a vanilla JS file, we’ll need some extra code in order to actually import it:

```auto
<script defer src=https://cdn.JsDelivr.net/npm/p5></script>

<script type=module>
  // Imports class SimplexNoise from module file "simplex-noise.min.js":
  import SimplexNoise from
    "https://cdn.JsDelivr.net/npm/simplex-noise/dist/esm/simplex-noise.min.js";

  // Makes imported class SimplexNoise globally available:
  globalThis.SimplexNoise = SimplexNoise;
</script>

<script defer src=sketch.js></script>

```

As you can see above, a module JS file needs the keyword `import` in order to grab it:

> **[import - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)**
>
> The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are called live bindings because they are updated by the module that exported the binding, but cannot be re-assigned...

I believe the template above should work this time. Good luck!

---

_[View the full topic](https://discourse.processing.org/t/simplexnoise-is-not-defined/33163)._
