module error
im getting a module error which wasnt there before, requiring me to add .js extensions to all imports. whats causing this? ^
[ Server!]
[ Server!] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/guinness/PetTreat/pets/app/.wasp/out/sdk/wasp/dist/ext-src/emails/orderjwt' imported from /home/guinness/PetTreat/pets/app/.wasp/out/sdk/wasp/dist/ext-src/emails/operations.js
[ Server!] at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
[ Server!] at new NodeError (node:internal/errors:405:5)
[ Server!] at finalizeResolution (node:internal/modules/esm/resolve:327:11)
[ Server!] at moduleResolve (node:internal/modules/esm/resolve:980:10)
[ Server!] at defaultResolve (node:internal/modules/esm/resolve:1206:11)
[ Server!] at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:404:12)
[ Server!] at ModuleLoader.resolve (node:internal/modules/esm/loader:373:25)
[ Server!] at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:250:38)
[ Server!] at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
[ Server!] at link (node:internal/modules/esm/module_job:75:36) {
[ Server!] url: 'file:///home/guinness/PetTreat/pets/app/.wasp/out/sdk/wasp/dist/ext-src/emails/orderjwt',
[ Server!] code: 'ERR_MODULE_NOT_FOUND'
[ Server!] }
8 Replies
Hi @Bruno Njeru. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error you're seeing—requiring you to add .js extensions to all imports—is due to how ES Modules work in Node.js when "type": "module" is set in your package.json. In this mode, Node.js requires all relative imports to include the file extension (e.g., .js), and omitting it will result in ERR_MODULE_NOT_FOUND errors like the one you posted.
This behavior is not specific to Wasp, but rather a quirk of the ES Modules system in Node.js. TypeScript, which Wasp uses, does not rewrite import paths to add .js extensions during compilation, so you must specify the correct extension in your imports. This has been discussed in the Wasp community and is a known source of confusion, especially after recent restructuring and updates to Wasp's code generation and SDK packaging. The Wasp team is aware that this can be confusing and is considering ways to make the experience more uniform and robust, but for now, you need to include the .js extension in your server-side imports for things to work correctly. This is also why you might see errors if you omit the extension, even if it worked before, as changes in the build or module system can expose these requirements more strictly than before Look at extension requirements when importing Jobs, Fix inconsistent import extensions in both .wasp file and in JS files., Improve error messages reported by the framework code.
In summary:
You must add the .js extension to your server-side imports when using ES Modules in Node.js, as required by the module system and enforced by Wasp's current setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
You must add the .js extension to your server-side imports when using ES Modules in Node.js, as required by the module system and enforced by Wasp's current setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
GitHub
Relative imports in user code combined with imports from `wasp/serv...
This is a problem we've had for a while but haven't properly documented. Users have also been known to hit it (example below). Steps to reproduce Create a project with Wasp 0.16 and make th...
Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for sharing the link to https://github.com/wasp-lang/wasp/issues/2492. However, based on the knowledge sources provided above, I do not have access to the content of that specific issue (#2492), so I cannot confirm or summarize its answer.
From the information available in the provided sources, the requirement to add .js extensions to imports is due to Node.js ES Modules behavior, especially when "type": "module" is set in package.json. This is a known issue discussed in the Wasp community, and it is not specific to Wasp but rather a result of how Node.js and TypeScript handle module resolution and import paths. If you omit the .js extension, Node.js cannot resolve the module, resulting in the ERR_MODULE_NOT_FOUND error you encountered. This has been discussed in several Wasp issues and is a common source of confusion after recent updates and restructuring in Wasp projects Look at extension requirements when importing Jobs, Fix inconsistent import extensions in both .wasp file and in JS files., Improve error messages reported by the framework code.
If you need more details from issue #2492, please provide its content or context, and I’ll be happy to help further!
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Bruno Njeru, 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?
@Bruno Njeru so, what was the exact problem for you, could you please describe and provide some code examples? It would be really helpful for us to know for the future and possibly to debug it and fix it in Wasp 🙏
ok, i was importing actions os the server side in operations. like so: import { module ) from 'wasp/server operations' and using the same actions on the server side. that brings up a module error that requires all the imports to have .js extensions. if you dont use operations on server side from 'wasp/server/operations' there is no module error. everything works fine @miho
here is the case https://github.com/wasp-lang/wasp/issues/2492
GitHub
Relative imports in user code combined with imports from `wasp/serv...
This is a problem we've had for a while but haven't properly documented. Users have also been known to hit it (example below). Steps to reproduce Create a project with Wasp 0.16 and make th...
Thank you for the description, I believe we fixed this in 0.16.0 so I'd suggest upgrading 👍 You version is 0.15.0 based on the Wasp file.
I've tried upgrading locally to 0.17.0 but you have a lot of type errors in your code, which you would need to fix as well (e.g. assigning a string to a number).
cc: @Filip just for awareness
cool
@miho most errors come from using JSON in my schema