Netlify functions not deploying when published via github

My Netlify functions don’t deploy when the site is built after a push to Github. But they do deploy when using the CLI netlify deploy --prod. Any idea what might be causing this?

Hi @ire, without seeing the repo it’s impossible to say. There’s no reason why they wouldn’t deploy unless you don’t specify a functions directory or the functions aren’t in there. Can you link to one of your builds? Also if the repo is public, can you share a link to it?

Hi @futuregerald! Thanks for the response!

I did specify the functions directory, here’s the repo:

And here’s a link to a build:

Hi @ire , that deploy you linked to has a function in it
It also looks like that was your last successful deploy and the function in it is live in production now:

Hi! So I deployed from the CLI after that. Typically when the site is deployed from the github repository, there are no functions available. That deploy I sent you isn’t what is currently published.

Hi, your currently published deploy is: I see the same thing for that.


I do see some of your deploys stuck in the ‘uploading’ state. Do you have any files in your deploy that are larger than 40Mbytes?

Hi @Dennis and @futuregerald

I found a better example, here’s a deploy preview: (you can see that there are no deployed functions there)

This is based off of this PR:

I don’t think my deploy is larger than 40MB, it’s hard to tell locally because I have some local dependencies that are larger.

Hi @ire, the function is in a sub-directory under /functions, you need to put it in the root of the functions directory for it to be deployed. If you put it in a sub-directory then your build process has to output the final zip archive or bundled function in the root of your functions directory.

Thanks @futuregerald . I was just following the documentation from here:

You can use either a standalone .js file that exports a handler (e.g. functions/{function_name}.js ) or a folder with the same name as a .js file in it that exports a handler (e.g. functions/{function_name}/{function_name}.js ).

It’s fine though, I figured out a workaround that doesn’t need the netlify function at all. Thanks!

1 Like

I’m having issues with this too, it looks like my function is getting built but not deployed.

It looks like you’ve set your functions directory to backend/dist/. That’s also what you’ve set as your publish directory. Without any information, I can’t say if that’s intentional or by accident. Either way, you’ll want to check to make sure you’ve set the correct directories.

1 Like

Ok, I created a brand new directory for just functions deployment but it seems to still not be working

What are the constraints on the deploy directory?

@ejohnson, your build’s publish directory is completely separate from the functions directory so that shouldn’t matter. However, it looks like your netlify-functions-dist folder is empty or does not contain functions. How are you building your functions? Where do you have your functions in your repository?

You can take a look at the different ways to deploy a function in this example repository. Let me know if that helps.

Thanks, I’ll try that out.