PrismarineJS/prismarine-viewer

`loadImage is not a function` when using Viewer in Next.js web client #235

Kae7in posted onGitHub

I'm using the prismarine-viewer package in a Next.js client to render a .schem file, and I have it to the point where there's a blank world loaded but the schematic is not displaying, and I get an error in utils.js?fc57:17: Uncaught (in promise) TypeError: loadImage is not a function

<img width="988" alt="Screen Shot 2021-12-19 at 10 54 23 AM" src="https://user-images.githubusercontent.com/5951996/146683610-0c1f1aba-3a40-4b6b-8ee3-d2b59b353959.png">

<img width="493" alt="Screen Shot 2021-12-19 at 10 54 31 AM" src="https://user-images.githubusercontent.com/5951996/146683611-056b9cd8-c15d-4844-a6ef-df7fb0e8dfcd.png">

Digging into the module, it appears that prismarine-viewer/viewer/lib/utils.js line 8, const { loadImage } = safeRequire('node-canvas-webgl/lib'), must not be loading, since a few lines later it gets called as a function but the error is thrown.

The portion of my web code where this is happening:

// Create viewer
const viewer = new Viewer(renderer);
viewer.setVersion(version);

I'm able to comment the viewer.setVersion(version); line out which removes this error. The screen then renders a blue skybox but does not show the schematic, and there still exists this error: worker.js:1 Uncaught SyntaxError: Unexpected token '<' (in worker.js:1)

Am I missing something here, or this truly an issue? Thanks!


I've wondered if this has to do with webpack somehow.

posted by Kae7in over 3 years ago

Fund this Issue

$0.00
Funded

Pull requests