W
Wasp-lang2mo ago
Sam79

What causes this rollup error?

What causes this rollup error when running wasp start?
[!] RollupError: src/server.ts (6:7): "default" is not exported by "../../../src/ServerSetup.ts", imported by "src/server.ts".
[ Server!] https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
[ Server!] src/server.ts (6:7)
[!] RollupError: src/server.ts (6:7): "default" is not exported by "../../../src/ServerSetup.ts", imported by "src/server.ts".
[ Server!] https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
[ Server!] src/server.ts (6:7)
6 Replies
kapa.ai
kapa.ai2mo ago
Hi @Sam79. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you're seeing is likely due to the way you're exporting your serverSetup function in your ServerSetup.ts file. In Wasp, if you define a serverSetup function without arguments, it can cause the server to crash with a similar error message. This is because the serverSetup function is expected to take one argument, which is the context. Here's an example of how you might be defining your serverSetup function:
export default async function () {
// Your code here...
}
export default async function () {
// Your code here...
}
To fix this error, you should modify your serverSetup function to take a context argument, like so:
export default async function (context) {
// Your code here...
}
export default async function (context) {
// Your code here...
}
This issue was discussed in a Github issue (https://github.com/wasp-lang/wasp/issues/1035) on the Wasp repository. The issue was closed, indicating that the solution provided was effective. Please try this solution and let me know if it resolves your issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sam79, 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?
Sam79
Sam792mo ago
@kapa.ai setup is like this:
export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('cors', cors({ origin: ['http://localhost:3000', 'http://192.x.x.x:3000'] }))
return middlewareConfig
}
export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('cors', cors({ origin: ['http://localhost:3000', 'http://192.x.x.x:3000'] }))
return middlewareConfig
}
@kapa.ai is that correct?
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain information about the specific Rollup error you're encountering when running wasp start. For more detailed help, I would recommend checking the Wasp documentation (https://wasp-lang.dev/docs) or the Wasp GitHub repository (https://github.com/wasp-lang/wasp) for similar issues. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sam79, 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?
Sam79
Sam792mo ago
@kapa.ai I changed the code slightly which stopped the problem. I then changed it back again and the problem has gone away. I can only assume it occurs randomly. Is it a bug? @kapa.ai what is your diagnosis?
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry, but I can't provide a diagnosis for the Rollup error you're experiencing. The knowledge sources provided do not contain information about this specific issue. For more detailed help, I recommend checking the Wasp documentation (https://wasp-lang.dev/docs) or the Wasp GitHub repository (https://github.com/wasp-lang/wasp) for similar issues. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sam79, 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?
Filip
Filip2mo ago
Hi @Sam79, I'm guessing you mixed a default import with a named export. If you use a default export in serverSetup.ts, you must use a default import in main.wasp. If you use a named export in serverSetup.ts, you must use a named import in main.wasp. I see you've used a named export in serverSetup.ts:
export const serverMiddleWare...
export const serverMiddleWare...
And I'm guessing you used a default import in main.wasp:
// wrong
middlewareConfigFn: import serverMiddleWare from '@src/serverSetup'
// wrong
middlewareConfigFn: import serverMiddleWare from '@src/serverSetup'
While the correct form in your case would be this (notice the curly braces):
// right
middlewareConfigFn: import { serverMiddleWare } from '@src/serverSetup'
// right
middlewareConfigFn: import { serverMiddleWare } from '@src/serverSetup'
Want results from more Discord servers?
Add your server