Home > database >  Getting error while tryting to import library
Getting error while tryting to import library

Time:11-21

I need help, I'am getting this error while trying to import library.

enter image description here

I got this library by the command: npm i queue

code how i import (javascript): import Queue from "./node_modules/queue/index.js"

HTML: <script type="module" src="./gamescript.js"></script>

How can i fix this problem?

CodePudding user response:

Do you have "type": "module" in your package.json ?

CodePudding user response:

while exporting from ./node_modules/queue/index.js file you need to mention default as shown below.

export default Queue(name of the module);

then you can import directly.

  • Related