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 do I get rid of this error while using npm package in client side JS?

I was learning socket.io and when I reached the client side part, I installed a package called socket.io-client as per my instructor. When I tried to use it in my client side JS, it threw me an error. My socket.io is configured to run in the port 3000. This is my first time trying to use npm packages in the client side JS. My instructor was this video: https://www.youtube.com/watch?v=ZKEqqIO7n-k&t=96s The error reads out like this:-

Uncaught TypeError: Failed to resolve module specifier "socket.io-client". Relative references must start with either "/", "./", or "../".

Here is my code:

import { io } from "socket.io-client";
const socket = io("http://localhost:3000");

Can anyone help me with this error?

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

0

try

    import {io} from "/server.js";
    const socket = io("http://localhost:3000");

this will make it work as you would have required the library on a different file

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