Not able to do import export functions in node.js project
I'm making a memory game, I want to export a function.
logic.js
app.js
the app is keep crashing, i tried changing
type
to module
in package.json, there was still no change5 Replies
What does the error say?
You're running on Node.js, which does not have access to the DOM.
I would recommend looking into Vite to create something for the browser, instead.
thanks
is there any other way where i dont have to use vite ?
You don't have to use Vite if you don't want to, it's just a convenience. You can use bare html, css and js files if you want to. There's also Webpack but I think that's much more complicated.
To get started, it's as simple as running this on the terminal
npm init vite@latest
. This will give you a dev server and a few other niceties.