Deploy express JS to netlify

I’m currently deploying my express file to netlify platform. All the tutorials are showing to use netlify-lambda package. But the package is deprecated and advised to use netlify cli. But for build command, tutorials suggesting netlify-lambda build, which is deprecated. I used normal build method like, ‘build application.js’. The sites deploys because I pointed correct folder path for fronted, but unfortunately api calls not working. It’s working with netlify-lambda build command, but as it’s deprecated it’s not a good approach. So can I know how to deploy with latest method?

Have you read through this article?

Yes. If you go through the application example provided, in github repo, you can see it’s uses netlify-lamda as well. Which is deprecated as I mentioned. So I need a solution that doesn’t inquire netlify-lambda as it’s deprecated and it’s already has High vulnerabilities, which I don’t think a good approach to use. So I’m waiting for a new solution. Thanks for the help though, I appreciate that

Here’s a live example: netlify-file-browser/api.js at v2 · Hrishikesh-K/netlify-file-browser · GitHub

1 Like

I need the build command in package.json , because my application already works fine in netlify with API calls, but with netlify-lambda which is deprecated. So if you can provide package.json or at least build comamnd, that would be helpful. Thank you for your response though

That’s an entire repo which has everything you need though?

But to answer your question, there’s no build command for Functions. Functions are built and packaged automatically.

Yes if there’s an updated guide that would helpful. Otherwise I guess we are again in square 1 in this discussion loop.

There’s no guide, nothing official from Netlify at least. You need to follow Netlify Functions’ documentation: Functions overview | Netlify Docs and write a function like this (just the minimum bare-bones):

import express, {Router} from 'express'
import serverless from 'serverless-http'
export async function handler(event, context) {
  const app = express()
  const router = Router()
  app.use('/api/', router)
  return serverless(app)(event, context)

add the following to your netlify.toml:

  external_node_modules = ["express"]
  node_bundler = "esbuild"
  force = true
  from = "/api/*"
  status = 200
  to = "/.netlify/functions/api/:splat"

and that’s it.

1 Like


We’ve updated our docs: Express on Netlify | Netlify Docs to make this more clear.

1 Like