Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
injune1123 opened this issue Feb 2, 2017 · 2 comments

Comments

@injune1123
Copy link

injune1123 commented Feb 2, 2017

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
Copy link
Author

injune1123 commented Feb 16, 2017

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.

@johntron
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants