alert("loading...");
let mod = require("/index.js");
alert("done!");
It says “loading…” but never gets to “done!”
I also tried putting those index.html lines in a setTimeout of 3000 to give it time to export, but that didn’t help.
require is a built-in function for NodeJS, it doesn’t exist in client side JavaScript. Could you provide a link (not a join link) to the repl you’re having difficulties with, it’d provide a little more context to your question and help others help you.
That’s because 1) index.js is not hosted, so you’ll get a 404 if you try to import it, 2) you’re not using import correctly, it’s not the same as Python imports nor is it a function, and you can only use import inside a script with type="module", you would have to do import { someVar, someFunc } from "index.js"; or import someDefault from "index.js";, 3) your index.js file is NodeJS, for all intents and purposes, this is an entirely different language to vanilla JavaScript and importing it will only cause errors.
What are you trying to do, with a better idea of what you want I’d be able to help you more.
My goal is to have data for a large amount of cards which is available to both the server and client; essentially, a large object with integers, strings, and functions. The data goes like this:
I haven’t tested that client side script, I’m not 100% sure about the way I used await, if that gives you an error, let me know.
This will allow you to send JSON data about each card to the client side, you could also just use Socket.IO to do this. If the client needed to respond on done way, it’d probably be best to use Socket.IO.