import local files fails while import() succeeds
I am trying to load a local file for side effects, however it seems that when using an import statement over an import function, node is unable to locate the file.
import "./gameUpdates.js";
// Uncaught Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'c:\Users\USER\Desktop\Code\blaseball\blasebot\bot\gameUpdates' imported from c:\Users\USER\Desktop\Code\blaseball\blasebot\bot\main.js
import("./gameUpdates.js");
// no error; imports sucessfully
both are top level, in the main file. looking around the internet, they should function the same, however they do not
this just got weirder; while the inital example does not import
import "../bot/gameUpdates.js";
does correctly import, both
do you have a repo or a gist you can share so we can see the repo structure of what you are working on?
https://github.com/BeeFox-sys/blasebot/tree/v2
currently everything uses the workaround previously mentioned, however changing it back to using the import statement in the inital issue, it once again fails to import
What platform are you running on? What version of Node, what flags (if any)? If you rename the file to be all lowercase, does that fix it?
Also import() is asynchronous. You need to put await in front of it in lines like https://github.com/BeeFox-sys/blasebot/blob/98019f19e8ec956a7a88e75bd04b57fc66b9dc49/bot/main.js#L26
Running on windows 10 home build 19043.1288, node version 16.6.2, --trace-warnings flag, and no lowercase does not solve the issue
and thank you for the info on the import function! I will be sure to update the relevant lines!