-
-
Notifications
You must be signed in to change notification settings - Fork 253
-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Error when building with Webpack 2.5: "Module not found: Error: Can't resolve 'canvas' #102
Comments
@ay5000 I have webpack |
@ay5000 We had the same issue -- webpack searches for dependencies before the code is run, so it doesn't realize that the
|
It is very strange that it doesn't realize that that code is unnecessary for a browser. Because it is defined in |
I can help. But I need reproducible repo. Where I can |
Well, I found the reason, and the reason is AspNetCore SPA. I use AspNet SPA + Webpack + React + Redux stack. The problem is that AspNetCore can't prerender the library using 'canvas' on the server side (libraries using 'window' won't work either). So I decided to turn off aspnet-prerendering option. It seems that Microsoft uses their own JS engine not compatible with V8. |
I have the same issue on meteor: the dev server still works, but building fails. |
We have this issue, too, but this time when using the electron-renderer webpack target. @lavrton in this case, the environment is a mixture of node and browser (somewhat like nwjs). Can the check in Konva be changed to detect the electron environment, or at least not consider it a node environment for the purposes of being built by webpack with the |
Should be resolved with the last version of Konva |
Sorry if this is the wrong issue, but I've wondered if there anyway Konva can do server-side rendering? There is Or perhaps my premise is faulty and it should work? |
@OKNoah no server-side rendering. |
@lavrton Right. Currently I do in my render function if (typeof window !== 'undefined') {
const Konva = require('react-konva')
return (<Konva.Rect .... />)
}
return null Maybe that's not necessary? But if it is, could we at least send this along as SSR'd: <canvas width="1132" height="748" style="padding: 0px; margin: 0px; border: 0px; background-color: transparent; position: absolute; top: 0px; left: 0px; width: 566px; height: 374px; background-position: initial initial; background-repeat: initial initial;"></canvas> Then we don't have a flash of canvas elements loading after page load (drawn on or not). Of course this is also achievable by just putting a div of the same size and shape, while that would require redrawing and a small performance hit. I'm just wondering. If React-Konva does need Maybe server-side could even generate an image, make it a png, and load it under a transparent canvas element on initial load? Pardon my ignorance if I'm way off. |
Generating png and returning it instead of a canvas is a very interesting idea. Please create another issue with your requirements and suggestions. I am happy to apply related PR. |
Still experiencing this issue with nextjs |
@stephenasuncionDEV did you look here https://github.com/konvajs/react-konva#usage-with-nextjs? |
@lavrton It seems issue happens once again, it should be connected with nextjs updates (changing of dynamic function) |
|
I am running into a webpack error with react-konva 1.1.3 and webpack 2.5:
ERROR in ./~/konva/konva.js
Module not found: Error: Can't resolve 'canvas' in '/******/node_modules/konva'
@ ./
/konva/konva.js 251:19-36/react-konva/src/react-konva.js@ ./
@ ./assets/js/index.js
Thanks.
The text was updated successfully, but these errors were encountered: