hashids: ReferenceError: require is not defined

695 views Asked by At

The following gives me an issue saying ReferenceError: require is not defined

var Hashids = require('hashids'), hashids = new Hashids('my salt', 8); 

I am using this hashids.js class.

The description says that this is a client-side version of Node.js version. I am not using bower so I just load the hashids.js on the page.

Are there any other javascript files I need to have this hashids.js is dependent on?

How do I get it working?

1

There are 1 answers

0
Pasang Sherpa On BEST ANSWER

You can't use node code in client-side unless you use library like browserify to load the module.

Try this instead -> https://github.com/ivanakimov/hashids.js/blob/master/lib/hashids.js