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

162
Visualizações
can't correctly import module w/ webpack

I am trying to learn Three.js by starting with a Three.js tutorial that uses webpack. (You can find the tutorial repo here.) Everything works until I try to import the midi-player-js package I installed with npm. Nothing I try works. I've tried the require syntax, as well as the import * as syntax. Different errors are thrown, but the most common is that Player (one of the module's classes) cannot be found.

What is going wrong? How can I import npm packages with this setup?

My sample script.js file looks like this, right now:

import * as MidiPlayer from "midi-player-js"

const player = new MidiPlayer.Player(function(event) {
    console.log("Ticked")
});

// Load a MIDI file
player.loadFile('PATH_TO_MIDI_FILE');
player.play();

Keep in mind that I've tried other import syntax's, though.

EDIT: Starter HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ThreeJS Starter</title>
</head>
<body>
    <canvas class="webgl"></canvas>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
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