ERR_MODULE_NOT_FOUND
Hello, I am using wasp 0.15.0, on linux mint
I recently got a problem with my wasp app, I am using the OpenSaas template, wich I've been using for a while now
the error code is the following
The wasp app compiles, it launches the server, the landing page is still accessible, but everything else is not working.
I don't know how I got this error, it worked until now and I think no changes were made.
I found only one post on the github talking about it and it didn't provide much help.
I think it has something to do with how to extensionsless imports are working in the /src file but not in the .wasp/out/sdk file
Could you please help me? It would mean a lot.
Thanks you for reading
13 Replies
Hi @Maelou. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Thank you for your detailed question about the ERR_MODULE_NOT_FOUND error you're experiencing with your Wasp app. This is indeed a Wasp-related issue, so I'll do my best to help you based on the information provided in the knowledge sources.
The error you're encountering seems to be related to module resolution, specifically with the file '/home/mael/strivea-dev/.wasp/out/sdk/wasp/dist/ext-src/payment/plans'. This type of error can occur due to various reasons, including missing files, incorrect import statements, or issues with how Wasp generates and resolves imports.
Based on the information available, here are a few suggestions that might help resolve your issue:
1. Clean and rebuild:
As suggested in a similar case, try running
wasp clean
to delete all .wasp and node_modules folders, and then run wasp start
to reinstall everything. This approach has helped resolve similar issues for other users. Discord support thread
2. Check file extensions:
There's a known issue with Wasp regarding inconsistent import extensions. Make sure your import statements in both .wasp files and JS/TS files include the correct file extensions. For server-side code, you might need to explicitly add '.js' to your imports. Github Issue #1363
3. Verify file existence:
Double-check that the file 'plans.js' (or 'plans.ts' if you're using TypeScript) exists in the directory '.wasp/out/sdk/wasp/dist/ext-src/payment/'. If it doesn't, you might need to create it or adjust your import statement.
4. Check Wasp version compatibility:
Ensure that your project is compatible with Wasp 0.15.0. If you've recently updated Wasp, there might be some breaking changes that affect how imports are handled.
5. Examine generated code:
Look into the generated code in the '.wasp/out/sdk/wasp/dist/ext-src/payment/operations.js' file to see how it's trying to import the 'plans' module. This might give you a clue about what's going wrong.
If these steps don't resolve the issue, it might be worth opening an issue on the Wasp GitHub repository. The Wasp team is aware that there are some error messages that are not easy to decipher, especially after recent restructuring, and they're working on improving them. Github Issue #1664
Remember, when dealing with import issues in Wasp, it's important to be aware of the differences between how imports work in your source files versus the generated files in the .wasp directory.
If you need further assistance, providing more details about your project structure, relevant code snippets, and any recent changes you've made could help in diagnosing the problem more accurately.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Maelou, 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?I have already and to try to solve the issue in the generated code, it still show the same error
I looked in the file, and I saw the payements plans were imported from , and not from , wich makes sence but In my code in the src file, the modules and files imports are extensionless, and if I put the extension manually in the .wasp/out/sdk files, I will reset every time I clean and rebuild.
Is there another way to automate the generated imports in the code? @kapa.ai
Let me check the knowledge base for you again. One moment! :books:
----------------------
Thank you for providing more details about your situation. I understand you've already tried cleaning and rebuilding, and you've identified the issue with the import statements in the generated code. Let's explore this further based on the information available in our knowledge sources.
The inconsistency between extensionless imports in your source files and the need for extensions in the generated code is a known issue in Wasp. This problem is related to how TypeScript and ESNext modules handle imports.
Unfortunately, there isn't a straightforward way to automate the addition of extensions in the generated imports without modifying Wasp itself. However, there are a few things you can consider:
1. Consistent use of extensions: In your source files, try using explicit extensions for all imports, including
.js
for JavaScript files and .ts
for TypeScript files. This might help Wasp generate the correct imports in the output. Github Issue #1363
2. Server-side import resolution: The Wasp team has considered configuring the server node process to handle imports without extensions. However, this solution hasn't been implemented yet. Github Issue #1363
3. Additional build step: Another potential solution that has been discussed is adding an extra build step to the server code that fixes extensions, similar to what is done on the client side. However, this is not currently implemented. Github Issue #1363
4. Manual workaround: As a temporary workaround, you could create a script that adds the necessary extensions to the imports in the generated files after each build. However, this would need to be run manually after each wasp clean
and wasp start
.
5. Report the issue: Since this problem persists and affects your workflow, it would be valuable to report this specific case to the Wasp team. They are actively working on improving error messages and resolving inconsistencies in the build process. Github Issue #1664
Given that this is a known issue without a current automated solution, the best course of action might be to report your specific case to the Wasp team. They might be able to provide a more tailored solution or prioritize fixing this issue in future releases.
In the meantime, you might need to manually adjust the imports in the generated code after each build, which is not ideal but could allow you to continue development while waiting for a more permanent solution.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Maelou, 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?@Wasp Team Sorry for pinging, is there really no other way? Thanks you :)
@kapa.ai is there a way to use a rollup.config.js file ? that would resolve the extensions?
You mentionned a script to add the necessary extensions to the import, how to do so?
Let me check the knowledge base for you again. One moment! :books:
Hey @Maelou, which issue did you find?
I believe we solved this issue in 0.16.1
Here it is: 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...
----------------------
I apologize, but the knowledge sources provided don't contain specific information about using a rollup.config.js file with Wasp or how it might resolve extension issues. Similarly, there's no detailed information about a script to add extensions to imports in Wasp projects.
However, I can provide some general insights based on the available information:
1. Custom build configurations: Wasp generates its own build setup, and there's no mention in the provided sources of supporting custom rollup configurations. Introducing a rollup.config.js file might interfere with Wasp's build process and is not a recommended approach based on the available information.
2. Extension handling: Wasp has its own way of handling extensions, which differs between client and server code. For example, the client-side code seems to have a step that fixes extensions, but this isn't present on the server side. Github Issue #1363
3. Scripting solution: While a script to add extensions was mentioned as a potential workaround, no specific implementation details were provided in the knowledge sources. Creating such a script would likely involve parsing the generated JavaScript files in the .wasp/out directory and modifying import statements to include the correct extensions. However, this would be a custom solution and not an official Wasp feature.
Given the lack of specific information about custom build configurations or extension-fixing scripts in Wasp, the most appropriate course of action would be to:
1. Report your specific issue to the Wasp team, as they are actively working on improving error messages and resolving inconsistencies in the build process. Github Issue #1664
2. Consider using explicit extensions in your source files, as this might help Wasp generate the correct imports in the output. Github Issue #1363
3. Wait for future Wasp updates that might address these import and extension issues more comprehensively.
If you need a more immediate solution, you might want to reach out to the Wasp community or developers directly for more specific guidance on custom build processes or scripts that work well with Wasp's architecture.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Maelou, 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?
Hello, I have'nt migrated to 0.16.0 yet, will try then, thanks you!
My error was a module not found error, with sdk generated code for the extensionless imports like
Yeah, I think that's it. Full details in the issue 🙂
Let me know if you still need help after updating!
Thanks you! Have a nice day
Will do
Just migrated, it now works, thanks you a lot!!
Wohooo @Maelou, you just became a Waspeteer level 1!
Glad I could help