Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

'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;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading