Ask coding questions

← Back to all posts
Modules
dfnk

Why is this not working? When importing?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
MANAV0201
dfnk
Comments
hotnewtop
Coder100

Hello, right now the script tag is not a module.

Fix

Adding type="module" will fix this. Happy coding!

dfnk

@Coder100 Is there a different way, I was wondering since I was using a NPM package?

Coder100

NPM is for the server-side. Usually, you would be using something like unpkg to get the module on the client-side. @dfnk

dfnk

@Coder100 I has already installed the package and have seen some guides. It was just not working for me so I was wondering if my code was wrong, to import it.

Coder100

Looks good to me, but you are using it wrong, type="module" is for the main script using the import functions. @dfnk

dfnk

@Coder100 What do you mean?

Coder100

Replaces to

@dfnk

dfnk

@Coder100 By any chance could you show me a simple repl of it working?

Coder100

sure @dfnk

dfnk

@Coder100 thanks

Coder100

i'm working on fixing it @dfnk

dfnk

@Coder100 Thanks so much

Coder100

np @dfnk

dfnk

@Coder100 What do you mean? np?

Coder100

no problem @dfnk

dfnk

@Coder100 Oh, sorry not that good at abbreviations.

Coder100
Coder100

Sorry for the time it took but I guess my browser is just being weird @dfnk

dfnk

@Coder100 np, thanks

Coder100

does it work? @dfnk