MohanRaj Balumuri MohanRaj Balumuri - 1 year ago 165
Javascript Question

how to use estraverse js library on client-side?

I was able to get estraverse via npm and get it work on a node app. But when when i tried to install it via bower for client side usage, the install failed saying "optionator package is not found". And when i tried to load the js file directly, it showing "Uncaught ReferenceError: exports is not defined" in the console.

Answer Source

Finally found the solution. Apparently the current estraverse code base is not working in a web browser but it works fine in browserify or webpack. Thus, you need to built estraverse using any of this module.

I used browserify to to built it using the code below:

browserify --standalone estraverse estraverse-master/estraverse.js > estraverse-master/build/estraverse.browser.js 

Now it works fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download