webSocket module not found
I'm experimenting with web sockets and ran into an unexpected error:
error TS2307: Cannot find module 'wasp/server/webSocket' or its corresponding type declarations.
As shown in the attached screen grab, the webSocket module is indeed missing. I've tried wasp clean
to no avail. Running Wasp 0.16.3
4 Replies
Hi @genyus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error
TS2307: Cannot find module 'wasp/server/webSocket' or its corresponding type declarations.
typically means that the generated SDK files (which include the wasp/server/webSocket
module) are missing or not properly built.
Based on the knowledge sources, here are some steps and considerations:
1. Wasp SDK Generation: The wasp/server/webSocket
module is not a package you install from npm, but rather a part of the SDK that Wasp generates when you run the compiler (e.g., with wasp start
). If the SDK is not generated correctly, these modules will be missing, leading to the error you see.
2. Try Cleaning and Rebuilding: Running wasp clean
followed by wasp start
is the recommended way to force Wasp to regenerate the SDK and reinstall dependencies. This has resolved similar issues for other users in the past, especially when the .wasp
or node_modules
folders become corrupted or out of sync. If this did not help, it suggests a deeper issue with the SDK generation or your project setup Discord support thread.
3. Correct Import Paths: Double-check that your import statement matches the expected path and that you are using the correct Wasp version. The documentation for web sockets shows imports like:
This should work if the SDK is generated properly and you are on a version of Wasp that supports this API Web Sockets Docs.
4. Wasp Version Compatibility: You mentioned using Wasp 0.16.3. The knowledge sources do not specify if there are breaking changes or missing features in this version regarding web sockets, but if you recently upgraded or downgraded, ensure your project is compatible with this version.
5. Potential Project Corruption: If you have a package.json
or node_modules
in a parent directory (outside your Wasp project), it can sometimes interfere with dependency resolution, as noted in a related issue Github Issue #1792.
If none of the above resolves the issue:
- The knowledge sources do not provide a definitive fix for this specific error on Wasp 0.16.3. It may be a bug or a version-specific issue.
- Consider sharing your project structure and the exact steps you took on the Wasp Discord or GitHub for more targeted help.
I'm sorry, but the knowledge sources do not contain enough information to provide a guaranteed solution for this specific error on Wasp 0.16.3. If you continue to experience issues, reaching out to the Wasp community with your project details may help uncover a solution.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @genyus, 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?Hey @genyus could you send your
main.wasp
or TS alternative?
Also the webSocket fn file.
Would love a bit more information.@toticozeni thanks for following up, I was able to figure it out this morning — I hadn't declared it correctly in my main.wasp.ts
Great, glad it worked out