How do I get rid of this error while using npm package in client side JS?

I was learning and when I reached the client side part, I installed a package called as per my instructor. When I tried to use it in my client side JS, it threw me an error. My 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: The error reads out like this:-

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

Here is my code:

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

Can anyone help me with this error?

1 answer

  • answered 2022-05-03 10:59 Fadedrifleman


        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

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum