# Problem requiring an external AMD module.

**URL:** <https://talk.observablehq.com/t/problem-requiring-an-external-amd-module/2230>\
**Category:** Help\
**Created:** [August 2, 2019, 1:40am UTC](https://talk.observablehq.com/t/problem-requiring-an-external-amd-module/2230 "2019-08-02T01:40:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vorth](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/vorth/32/954_2.png) [@vorth](https://talk.observablehq.com/u/vorth)\
**Post date:** [August 2, 2019, 1:40am UTC](https://talk.observablehq.com/t/problem-requiring-an-external-amd-module/2230/1 "2019-08-02T01:40:54Z")

</div>

I’m having an odd problem with require() and an external JavaScript module. (I added the AMD details so it would load as a module.) When loaded from a local file picker, the module is fine. When the exact same JavaScript is loaded from a Gist, the module is invalid.

[Here is the notebook](https://observablehq.com/d/412148a94a53fd82) demonstrating the problem, with more details in the text content.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [August 2, 2019, 1:49am UTC](https://talk.observablehq.com/t/problem-requiring-an-external-amd-module/2230/2 "2019-08-02T01:49:24Z")

</div>

You’re getting an error because the [gist.github.com](http://gist.github.com) link you used returns the file as type `text/plain`. One way to fix this is to paste the gist link on [raw.githack.com](http://raw.githack.com) and use either of the resulting URL(s) instead:

[https://gist.githack.com/vorth/c8f811806e5ade9341a0e588b7ba3320/raw/f840e7bdc396638d800d5706a3ae83d6b23a1e42/ZomicParser.js](https://gist.githack.com/vorth/c8f811806e5ade9341a0e588b7ba3320/raw/f840e7bdc396638d800d5706a3ae83d6b23a1e42/ZomicParser.js)

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [August 2, 2019, 2:16am UTC](https://talk.observablehq.com/t/problem-requiring-an-external-amd-module/2230/3 "2019-08-02T02:16:19Z")

</div>

Yep, what @bgchen said! GitHub doesn’t let you serve JavaScript files from Gists, I believe for security reasons. In addition to using something like GitHack to serve files from Gists, you can also jump through this hoop by fetching the file and using URL.createObjectURL:

```auto
parserModule = require.alias({
  "antlr4": antlr4,
  "ZomicParserListener": ZomicParserListener
})(URL.createObjectURL(await fetch(badURL).then(response => response.blob())))

```

---

<div class="post-metadata">

**Author:** ![vorth](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/vorth/32/954_2.png) [@vorth](https://talk.observablehq.com/u/vorth)\
**Post date:** [August 2, 2019, 3:21am UTC](https://talk.observablehq.com/t/problem-requiring-an-external-amd-module/2230/4 "2019-08-02T03:21:51Z")

</div>

Awesome, thank you both!
