Search code examples
catalystbyzohozohocatalystcatalystserverless

Error: The default export is not a function


I tried testing a Catalyst Node function locally using the command "catalyst serve". But when I tried accessing the Function URL("https:localhost:3000/server/node_function/health") I keep getting the below error:

Error: The default export is not a function at Server.aioHandler (file:///usr/local/lib/node_modules/zcatalyst-cli/lib/serve/server/lib/node/server/index.js:28:10)

You can find my Node function below:

'use strict';
var express = require('express');
var app = express();

app.use(express.json());

app.get('/health', async (req, res) => {
    res.sendStatus(200);
})

Solution

  • You might have faced this issue if you haven't exported your Express App module at the end of your function. You can add the below line in your function code and try executing your function again which should resolve the default export is not a function error.

    module.exports = app;