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
'window is not defined' error when importing #15
Comments
@micchyboy can you provide more context please? In particular, where are you trying to run your app? (e.g. browser?) |
I get the same issue. I am trying to run my app in the browser, and I set it into my component. But once it reloads I get the error. Not sure what further information you require but I get the same error as @micchyboy just from the import itself. |
@hect1c code samples, or even better, isolated failing examples always help. At the moment, all I have to go on is the fact that both of your basic imports are throwing an error. I've created my own examples using the Since other users are not reporting such a fundamental issue (see #14 that was closed a day or so ago), it sounds like something to do with either or both of your setups that I'm not familiar with. This could include things like how you're bundling your app. Beyond that it feels like I'm guessing too much, so anything extra you can provide will help me diagnose and hopefully fix the issue faster for you both. |
This error is also on our side. When we compile the ECMAScript 6 Code with Babel in webpack. The stacktrace looks then like this:
|
Thanks @tcompart, that's what I was thinking it might be. Be good to hear back from someone once it's sorted, even if it's just to share a snippet of webpack config, so the solution can be found in future 👍 |
UPDATE: I found another library that doesn't error when rendered on the server. I've actually really enjoyed using UPDATE 2: See below, 2.1.19 fixes the problem. I get this error when trying to build a static site with Gatbsy. Anyone working on a solution or know of an alternative svg tool that can handle windowless rendering?
|
@kaifaust hmm yea, looks like a somewhat common issue: gatsbyjs/gatsby#309 Just published |
That worked, thanks for addressing that! I'm happy to revert back to your library, here's the difference in my project:
vs
|
@kaifaust good news! Yea looks cleaner eh 👍 |
Why am I getting an error
node_modules/svg-injector/svg-injector.js:464 }(window, document)); ^ ReferenceError: window is not defined
I just installed and imported
import ReactSVG from 'react-svg';
Throws me the error.
The text was updated successfully, but these errors were encountered: