question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Turns out we couldn't find your server instance. Did you write `module.exports = app`?

See original GitHub issue

Hey, 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
msyyncommented, Mar 17, 2021

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 before

0reactions
msyyncommented, Mar 17, 2021

Module exports doesn’t seem to help either. Experiencing the issue with this at least: https://github.com/msyyn/sapper-discord-supabase-tailwind

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found