-1

I am getting this error while trying to import a library.

Error

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?

2
  • As a guess: import Queue from "./node_modules/queue/index.js" -> import { Queue } from "./node_modules/queue/index.js" Commented Nov 20, 2021 at 14:26
  • I don't think browsers have any cjs compatibility like node, so you can't just import a cjs module. Commented Nov 20, 2021 at 14:44

1 Answer 1

-1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, i have it in package.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.