Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
Installing troika-three-text from npm not working?

I need to add some texts to a scene in three-js and I've seen Troika seems to be perfect for it. The problem is that when I install troika, I can't find a way to call the module, and/or it has problems with references... I don't seem to find anything related anywhere, people ask questions like they simply install troika and voi-la, and for me it's been complicated

so I have three running perfectly, then I install troika (npm install troika-three-text)

it generates some folders in the node_modules folder, now the instalation tells you that you have to call it using

import { Text } from 'troika-three-text',

when I do this, I get this message:

'Uncaught TypeError: Failed to resolve module specifier "troika-three-text". Relative references must start with either "/", "./", or "../".'

so then I try with:

import { Text } from '../node_modules/troika-three-text/dist/troika-three-text.esm.js'

and now the problem is the following...

'Failed to resolve module specifier "troika-worker-utils". Relative references must start with either "/", "./", or "../".'

So I don't know what to do, either I have to manually change every path inside the scripts of all the troika folders, or what? it doesn't make any sense, please someone help me U_U thank you!!!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I just ran into this problem as well while playing, with troika.

This may not be a perfect solution,but it's a good workaround because I use three.js in the browser, not in nodejs. My main script is loaded in the index.html file using type="module" and also in the index.html file is an "import map" that uses defines the necessary names as follows:

<html>
  <head>

    <script type="importmap">
      {
      "imports" : {
          "three": "http://unpkg.com/three@latest/build/three.module.js",
          "troika-three-text": "http://unpkg.com/troika-three-text@latest/dist/troika-three-text.esm.js",
          "troika-three-utils": "http://unpkg.com/troika-three-utils@latest/dist/troika-three-utils.esm.js",
          "troika-worker-utils": "http://unpkg.com/troika-worker-utils@latest/dist/troika-worker-utils.esm.js",
           ...
      }
      }
    </script>

Note that I'm getting these files from the unpkg.com CDN. You may have to do something a bit different.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda