ERR_MODULE_NOT_FOUND due to double .js.js extension in name?
Have any of you had this error message before?
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/howcaniexplain/Desktop/CodingProjects/Project/Project/app/.wasp/out/sdk/wasp/dist/ext-src/server/actions.js.js' imported from /Users/howcaniexplain/Desktop/CodingProjects/Project/Project/app/.wasp/out/sdk/wasp/dist/server/operations/actions/index.js
I am recieving this error for queries and actions, where it seems to be looking for queries.js.js and actions.js.js instead of queries.js and actions.js. Actually going and manually changing both files to include the extra extension (ie making it queries.js.js and actions.js.js) actually fixed the error messge, but not really the ultimate issue as it is messy and Wasp created an additional copy of queries.js and actions.js now.7 Replies
Hi @howcaniexplain. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, it seems like there might be an issue with how Wasp is handling file extensions during import. There are several discussions about inconsistent import extensions in both .wasp files and in JS files, and how this can lead to confusion and errors.
For example, in this Github issue (https://github.com/wasp-lang/wasp/issues/1363), a contributor suggests that inconsistent extensions can be confusing not only in the Wasp file, but also across all server-side code. They provide examples of how some imports work fine without an extension, while others require the
.js
extension.
In another Github issue (https://github.com/wasp-lang/wasp/issues/1664), a member mentions that if a path to a server file is provided in main.wasp without a .js
extension, it doesn't work and results in an ERR_MODULE_NOT_FOUND
error, similar to the one you're experiencing.
While these discussions don't directly address your issue of a double .js.js
extension, they do suggest that there might be some inconsistencies or bugs in how Wasp handles file extensions during import.
As a temporary workaround, you might want to try manually removing the extra .js
extension from your import statements, if possible. However, it would be best to report this issue to the Wasp team so they can investigate and provide a more permanent solution.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @howcaniexplain, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@howcaniexplain can you share what these imports look like in your
main.wasp
file?Hey @howcaniexplain ! You likely have an import in Wasp file that has .js at the end. Can you drop that
.js
at the end? That should solve it. This is a "bug" on our side that Wasp is so fussy about it and doesn't report a great error message, we opened an issue for it here https://github.com/wasp-lang/wasp/issues/2096 .GitHub
Resolving
ext-src
imports in the SDK if the user declares an impo...Users get a weird error saying they can't import queries.js.js something something. I've reproduced with the latest Wasp version: 0.13.2 As far as I can see, it seems related to the exports...
@martinsos Sorry for going completely silent. But yeah, I was using the OpenSaaS boilerplate which imported actions.js and queries.js with the .js included in the name. Removing the .js file extension did seem to solve the issue though. Was odd because the issue was nonexistent until one day it wasn't.
Wohooo @howcaniexplain, you just became a Waspeteer level 1!
Open SaaS has
.js
for lots of imports. Weird that it doesn't cause issues for other users. Should I create an issue to remove the extension from the wasp file?Yeah, maybe let's remove it for now, as that is the safest. We have to hunt down what is causing this, I belive there was a minor uopdate to Typescript and maybe newer Wasp projects are pulling that in? Hm.
We did add this as something to fix for next release, so should be fixed in the next weeks