Turns out we couldn't find your server instance. Did you write `module.exports = app`?
See original GitHub issueHey, I am receiving the following error and couldn’t get around what is causing it…
My deploy works just fine and finishes with no errors whatsoever, but when I load the site on Vercel it shows this in place of my site:
typeof: function (expected 'function')
String: (req, res) => {
res.writeHead(500, { 'Content-Type': 'text/plain' })
res.write('This is vercel-sapper, your Vercel builder. Turns out we couldn\'t find your server instance. Did you write "module.exports = app"?
typeof: ${typeof listener} (expected 'function')
String: ${String(listener)}
Read the docs or create an issue: https://github.com/thgh/vercel-sapper')
res.end()
}
Read the docs or create an issue: https://github.com/thgh/vercel-sapper
I tried doing what the error says; exporting it with module.exports too. My other project is using similar server file and it’s working just fine?
This is my server.js:
import express from 'express';
import compression from 'compression';
import * as sapper from '@sapper/server';
import cookieParser from 'cookie-parser';
import { json } from 'body-parser';
import supabase from './supabase';
const { PORT, NODE_ENV } = process.env;
const dev = NODE_ENV === 'development';
export default express()
.use(cookieParser())
.use(json())
.use(
compression({ threshold: 0 }),
sirv('static', { dev }),
sapper.middleware({
session: async (req, res) => {
// If there's a JWT, check if it's valid
const results = await supabase.auth.api.getUser(req.cookies['supaToken']);
if (results.user) {
return { userToken: req.cookies['supaToken'] };
}
return { userToken: false };
}
})
)
.listen(PORT, err => {
if (err) console.log('error', err);
});```
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Getting err no exports found in module when deployed to vercel
I deployed my nodejs server with sequelize and sequelize cli, when I deploy application to vercel with having folder only index.js in models ......
Read more >How I solved and debugged my Webpack issue through trial ...
Try to check boilerplates and see how the feature is implemented there, like create-react-app for instance. Ask questions on StackOverflow — do ......
Read more >Node.js Export Module - TutorialsTeacher
Learn how to export different types as a Node.js modules here. ... In the above example, we have attached a property SimpleMessage to...
Read more >Understanding module.exports and exports in Node.js
James shows how to work with modules in Node.js, focusing on how to export and consume them, and explaining the difference between ...
Read more >Modules • JavaScript for impatient programmers (ES2022 ...
Exports : If we want any declared entity to be exported, we must explicitly mark it as an export. Imports: Each module can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay so module.exports works… I just had to do it like this:
const app = (module.exports = express())
and it goes through. 😄
had it as
module.exports = app
beforeModule exports doesn’t seem to help either. Experiencing the issue with this at least: https://github.com/msyyn/sapper-discord-supabase-tailwind