# Using reference implementation in client-side CommonJS environment

**URL:** <https://talk.commonmark.org/t/using-reference-implementation-in-client-side-commonjs-environment/2214>\
**Category:** Implementation\
**Created:** [August 31, 2016, 1:37am UTC](https://talk.commonmark.org/t/using-reference-implementation-in-client-side-commonjs-environment/2214 "2016-08-31T01:37:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DougReeder](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/dougreeder/32/1026_2.png) [@DougReeder](https://talk.commonmark.org/u/DougReeder)\
**Post date:** [August 31, 2016, 1:37am UTC](https://talk.commonmark.org/t/using-reference-implementation-in-client-side-commonjs-environment/2214/1 "2016-08-31T01:37:48Z")

</div>

I’ve been pulling in the JS reference implementation into my web app ([https://serenenotes.hominidsoftware.com/](https://serenenotes.hominidsoftware.com/)) for a year now. Thanks; that works great!

Now a framework change forces me to use CommonJS style requires. I can call  
`commonmark = require('./commonmark')` but then it wants to pull in all the modules that commonmark pulls in: node, common, inlines, mdurl/encode, mdurl/decode, entities, etc.

So, what is the correct way to use the reference implementation in a CommonJS environment that isn’t Node.js?

---

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [September 2, 2016, 9:06am UTC](https://talk.commonmark.org/t/using-reference-implementation-in-client-side-commonjs-environment/2214/2 "2016-09-02T09:06:50Z")

</div>

Use `dist/commonmark.js` from the repository (or the minimized version). It has no dependencies.

---

<div class="post-metadata">

**Author:** ![DougReeder](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/dougreeder/32/1026_2.png) [@DougReeder](https://talk.commonmark.org/u/DougReeder)\
**Post date:** [September 4, 2016, 4:29am UTC](https://talk.commonmark.org/t/using-reference-implementation-in-client-side-commonjs-environment/2214/3 "2016-09-04T04:29:17Z")

</div>

That’s what I’ve been using. `dist/commonmark.js` works fine imported from a script tag, but can’t be loaded using  
`commonmark = require('./commonmark')`

Fortunately, I can run `npm install commonmark` and then use  
`commonmark = require('../node_modules/commonmark')`
