superagent-no-cache icon indicating copy to clipboard operation
superagent-no-cache copied to clipboard

Works find in action.js file 1, but the project won't compile when trying to use the module in another file

Open injune1123 opened this issue 9 years ago • 2 comments

Hi there,

I am building a react flux project using Node: v4.4.4, "react": "^15.3.2", "react-dom": "^15.0.1", "flux": "2.0.1",

I added the line ( import noCache from 'uperagent-no-cache';) in one of my action.js file

Worked great! But every time I try to put the EXACT SAME import statement in another action.js file, the project won't compile.

Got an error node_modules/superagent-no-cache/node_modules/component-ie/index.js:16 el = document.createElement('b'), ^

ReferenceError: document is not defined

Does anyone has any clue why this is happening?

injune1123 avatar Feb 02 '17 18:02 injune1123

I am not sure whether this is the best solution, but after changing "import noCache from 'superagent-no-cache';" to

"var isBrowser = typeof window !== 'undefined'; "var noCache = isBrowser ? require(‘superagent') : undefined;"

It worked.

The reason it broke is similar to issue #10 . Node environment does not have "ie", thus I added the ternary expression.

injune1123 avatar Feb 16 '17 15:02 injune1123

@injune1123 I believe #23 should solve this problem. Do you agree?

johntron avatar Jul 22 '17 22:07 johntron