3

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.

  • Do you happen to find the solution for the error"Uncaught ReferenceError: exports is not defined"? I face the same error too. Thanks! – iLoeng Sep 16 '15 at 00:24

1 Answers1

4

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.

iLoeng
  • 434
  • 1
  • 4
  • 14
  • 1
    *"is not working in a web browser but it works fine in browserify or webpack"* browserify and webpack are not JavaScript environments. They don't execute JavaScript code, so code cannot work "in" them. They are module bundlers which bundle modules into a single file so it can be executed in browsers. – Felix Kling Dec 23 '15 at 23:21