Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught Error: define cannot be used indirect

I'm using webpack and babel to transpile my es6/jsx files in a node express React app I'm making. Everything is fine until I include the google spreadsheet npm module and attempt to import it into my project.

I get the error Uncaught Error: define cannot be used indirect but there is no define statement inside the imported module. This error only shows up in the browser, not in my console when webpack bundles my files, and completely stops anything from rendering on the page.

I think this is something to do with AMD/Commonjs but I am too inexperienced to know for sure, or what to even do if that were the case. Any help would be appreciated

like image 542
JmJ Avatar asked Mar 19 '16 18:03

JmJ


1 Answers

Just a shot in the dark, but I ran into the same error with different library. It could be that google spreadsheet depends on json-schema too. Try putting this in your webpack config:

module: {
  noParse: /node_modules\/json-schema\/lib\/validate\.js/, // <-- This
  loaders: [
    //all your loaders...
   ]
  }
like image 60
mikewilliamson Avatar answered Oct 20 '22 13:10

mikewilliamson