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

199
Visualizações
How to use peerjs (import and require both fail)

I want to use peerjs in a script (that I use in a html file). When I try import Peer from "peerjs", I get an error saying "Cannot use import statement outside a module". When I try var Peer = require("peerjs"), I get an error saying simply "require is not defined". Is there a way to use peerjs ? If yes, what is it ?

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

0

if you want to use a library inside an HTML file you need to include its file in a script tag.
for example in your case, PeerJS documentation instructs to add this line:

<script src="https://unpkg.com/peerjs@1.3.2/dist/peerjs.min.js"></script>

and then you can create a peer and connect.

take a look here: PeerJS

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