When I import NDK I keep getting this error:

Uncaught SyntaxError: Cannot use import statement outside a module

What is a module? What am i doing wrong? 🙂

#asknostr

Reply to this note

Please Login to reply.

Discussion

It’s hard to say without knowing exactly what you’re doing. ChatGPT is great for helping you with this kind of stuff.

import statements cannot be used in normal javascript functions you embed in HTML,without doing something called modularization.

Depending on your situation, one of the examples in this page can help you - https://www.w3schools.com/js/js_modules.asp

If you are running in nodejs, you might want to start with a `npm init` command, add ndk using `npm add ...` command suggested by ndk and then write your code in the index.js file, then run as `node index.js.`

Good luck with NDK BTW :)

It seems you are trying to run NDK in the server side.

Do you use a framework? Next? React? Or others?