Error: Uncaught TypeError: Failed to resolve module specifier “web3”. Relative references must start with either “/”, “./”, or “../”

I have installed web3 using npm in my project. I now have a web3 folder in my node_modules folder. However, when I run my code on local server, it shows the following error:

Uncaught TypeError: Failed to resolve module specifier “web3”. Relative references must start with either “/”, “./”, or “../”. (network.html:1)

In my networks.js file, I have done “import { Web3 } from ‘web3’;” and in my network.html file, inside script, I have added

type=”module” src=”/js/networks.js”

and

src=”https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js”

I tried to write the import statement in my .js file as a relative location i.e. ./web3 , /web3, ../web3. However, it still shows the same error.

Any help would be appreciated!

Thanks!