4

This can be reproduced by 3 simple steps.

  1. Create a new Create React App: npx create-react-app myApp

  2. Install Google Closure Library: npm install google-closure-library

  3. Import closure library into App.js: require('google-closure-library');

Now running the react app with npm start we get an exception in the browser console. Uncaught SyntaxError: Identifier 'module' has already been declared.

Trying to use goog.require(...) or anything similar results in a compiler error stating: Failed to compile. 'goog' is not defined. This is probably a side effect of the first error.

There seems to be a module variable in the google closure library that does not play well with another module variable already existing in the react app.

Is google-closure-library simply incompatible with create-react-app or what is going on here?

Skillzore
  • 748
  • 7
  • 21

0 Answers0