Cannot get threejs working with remix run, despite ClientOnly & .client
See original GitHub issueWhat version of Remix are you using?
1.4.0
Steps to Reproduce
Clone and run the following repo: https://github.com/harrisrobin/remix-run-three
Expected Behavior
I would expect remix to be able to work with a library such as three, especially when using <ClientOnly> and .client extension.
Actual Behavior
If you try to load a file that uses threejs, you will encounter the following error:
marked is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
✘ [ERROR] Could not resolve "three/examples/jsm/controls/OrbitControls"
app/components/harris-model/harris-model.client.tsx:3:30:
3 │ ... { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The module "./examples/jsm/controls/OrbitControls" was not found on the file system:
node_modules/three/package.json:14:24:
14 │ "./examples/jsm/*": "./examples/jsm/*",
╵ ~~~~~~~~~~~~~~~~~~
You can mark the path "three/examples/jsm/controls/OrbitControls" as external to exclude it from the bundle, which will remove this error.
✘ [ERROR] Could not resolve "three/examples/jsm/loaders/GLTFLoader"
app/components/harris-model/model.client.ts:1:27:
1 │ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The module "./examples/jsm/loaders/GLTFLoader" was not found on the file system:
node_modules/three/package.json:14:24:
14 │ "./examples/jsm/*": "./examples/jsm/*",
╵ ~~~~~~~~~~~~~~~~~~
You can mark the path "three/examples/jsm/loaders/GLTFLoader" as external to exclude it from the bundle, which will remove this error.
This is despite me adding ‘three’ to the serverDependenciesToBundle inside remix.config.js
Issue Analytics
- State:
- Created a year ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Remix says "server code in client modules" but that doesn't ...
Just migrated an application from react to Remix and I'm getting an error which doesn't help me to debug.
Read more >Gotchas - Remix
Server Code in Client Bundles. You may run into this strange error in the browser. It almost always means that server code made...
Read more >I am trying for hours but can not import and use three.js
-Test, and it works. However, I when I try to also import either OrbitControls or GLTFLoader I get the error: Uncaught TypeError: Error...
Read more >"Remix 3D Blast" by Nick Small at #RemixConf - YouTube
Whether you want to progressively enhance a traditional website or build an immersive 3D experience, Remix gives us a powerful and fun ...
Read more >How to Create an Interactive NFT with Remix and threejs
However, there are a couple of things you should know. You can not use a webcam for your sketch since Opensea doesn't support...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @WesleyTheGeolien Yes that is exactly what I did to get it working. Though I still feel that Remix should be able to import from threejs.
You can copy the OrbitControls and GLTFLoader source files to the app directory and resolve this issue…