Netlify-lambda doesn't build functions created with netlify cli

I am trying to use netlify-lambda to build my netlify functions so that I can write them in typescript. The issue I’m running into, though, is that netlify cli scaffolds new functions into subdirectories which netlify-lambda doesn’t seem able to pick up on.

For example, if I use the CLI to create two functions, the output looks like this:

serverless/
   my-function/
         my-function.ts
   my-other-function/
         my-other-function.ts

This is my netlify.toml

[build]
  command = "yarn build"
  functions = "build-serverless"
  publish = "build"

[[redirects]]
  from = "api/*"
  to = "/.netlify/functions/:splat"
  status = 200

This is what I have under scripts in package.json

"scripts": {
    "start": "run-p start:**",
    "start:app": "react-scripts start",
    "start:lambda": "netlify-lambda serve serverless",
    "build": "run-p build:**",
    "build:app": "react-scripts build",
    "build:lambda": "netlify-lambda build serverless",
...etc
}

However, when I run yarn build:lambda, this is the output

❯ yarn build:lambda
yarn run v1.7.0
$ netlify-lambda build serverless-copy/functions
netlify-lambda: Building functions

      ---Start netlify-lambda notification---
      WARNING: No valid single functions files (ending in .mjs, .js or .ts) were found. 
      This could be because you have nested them in a folder.
      If this is expected (e.g. you have a zipped function built somewhere else), you may ignore this.
      ---End netlify-lambda notification---

Furthermore, if I update the build:lambda script to:

"build:lambda": "netlify-lambda build serverless/*"

then it will build the function in the first directory (my-function.ts builds to build-serverless/my-function.js), but none of the others get built.

Is there a way to get netlify cli and netlify-lambda to work together?

Try changing serverless to serverless/*, I tried that locally and it built my functions in subdirectories just fine!

Can you share what your netlify.toml looks like?

At the bottom of my post I mentioned that I have tried
"build:lambda": "netlify-lambda build serverless/*" but still no luck

You are right, I don’t know how I missed your actual question. Now that I read it correctly I too have the same problem as you. Sorry! :slight_smile:

I have no clue other than to move those files out of their subdirectories. Again, sorry I can’t be of more help.