简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM