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

234
Visualizações
How to properly import THREE js library?

I installed the three library via npm. In the node_modules directory there is the three folder. But when I wanted to import it using:

import * as THREE from 'three';

it gives the following error:

ReferenceError: regeneratorRuntime is not defined

But when I use;

import * as THREE from 'three/build/three.cjs';

it properly works. Also, the same problem occurs while importing external plugins:

import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";

How can I fix this?

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

0

Three.js uses ES6 async/await, you need to upgrade or configure your babel presets to support async/await. This may help Babel 6 regeneratorRuntime is not defined

about 4 years ago · Juan Pablo Isaza Relatório

0

Make sure that you reference the correct path where your three.module is. I'd try the following for a script being in the rootForlder/src/theScriptWhereYourImportIs.js:

import * as THREE from '../node_modules/three/build/three.module.js';

If the script is at the same hierarchy level as your node_modules folder then the following should work:

import * as THREE from './node_modules/three/build/three.module.js';

As far as I remember I had to make some trials and figure this out as it was not very clear in the documentation. Any insight will be welcomed.

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