question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot get threejs working with remix run, despite ClientOnly & .client

See original GitHub issue

What 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: CleanShot 2022-04-16 at 19 47 23@2x

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:closed
  • Created a year ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
bushbladecommented, Oct 26, 2022

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.

1reaction
chenc041commented, May 2, 2022

You can copy the OrbitControls and GLTFLoader source files to the app directory and resolve this issue…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found