Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 624
MohanRaj Balumuri Avatar asked Oct 17 '25 23:10

MohanRaj Balumuri


1 Answers

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.

like image 152
iLoeng Avatar answered Oct 20 '25 13:10

iLoeng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!