Home
Support Forums

[Netlify functions] TypeError on hitting function from netlify dev

I deploy locally using netlify dev on netlify-cli@5.4.1 installed globally.

The (relevant) output is as follows

◈ Loaded function test.
◈ Functions server is listening on 56559
◈ Starting Netlify Dev with Create React App

However when I hit this function using postman or some other HTTP client the instance crashes with the following error

Request from ::1: GET /.netlify/functions/test
TypeError: Cannot read property 'join' of undefined
    at formatLambdaLocalError (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/synchronous.js:36:100)
    at handleErr (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/synchronous.js:40:55)
    at handleSynchronousFunction (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/synchronous.js:17:12)
    at handler (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/server.js:102:7)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
TypeError: Cannot read property 'join' of undefined
    at formatLambdaLocalError (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/synchronous.js:36:100)
    at handleErr (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/synchronous.js:40:55)
    at handleSynchronousFunction (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/synchronous.js:17:12)
    at handler (/Users/eddyoc/.config/yarn/global/node_modules/netlify-cli/src/lib/functions/server.js:102:7)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

This function works fine when deployed on netlify. However it makes it impossible for me to locally run or debug my functions

Welcome to the forums @eddyoc

Are you able to share you code so that others may assist in determining what you are trying to join and why it is undefined?

The code is hello world. The error is being thrown inside netlify-cli. Note that this only happens locally, there are no errors once this is deployed.

const handler = async (event, context) => {
  return {
    statusCode: 200,
    body: JSON.stringify({ message : 'hello world' }),
  };
};

module.exports = {
  handler,
}

I see you opened an issue too Cannot read property 'join' of undefined · Issue #3050 · netlify/cli · GitHub. Have you tried they suggestions posted there?