Function scaffolding via CLI

Per the article here (https://css-tricks.com/netlify-functions-for-sending-emails/), there is an example shown where a function is scaffolded like so: netlify functions:create --name hello-world. When I try this, I’m told:

◈ No functions folder specified in netlify.toml or as an argument

I’ve tried various help commands with the CLI, but none seem to say how I specify the functions folder as an argument. Is that defined anywhere?

As an aside, I did get past this. Turns out that when I opened terminal in VSCode, it wasn’t in the project folder. When I switched, everything worked, but I still would like to know how to specify the functions folder at the command line.

I think, if you set it in the netlify.toml file, it should work automatically for you:

[build]
functions = "<path/to/your/folder>"
1 Like

Right, but the CLI suggests you can also pass it as an argument. What is that argument?

According to the source of the plugin, i don’t think you can set it as an argument but, if you have an empty netlify.toml file with the lines i mentioned above then it will create the folder with the functions in it.

1 Like

Ok so if the error says you can, then this comes down to a bug, right? :slight_smile:

Yeah the message needs to get updated.

These are the only flags right meow https://github.com/netlify/netlify-dev-plugin/blob/3c71022a479524b9cd322d2516ecf2bb6f0cb9b9/src/commands/functions/create.js#L61-L63

Opened a PR to update that misleading log

Thanks for report @cfjedimaster

And thanks @zltnvrs for helping out as well =)

Set the function path in the netlify.toml for this to work

1 Like

Yes - big thanks to @zltnvrs and @cfjedimaster! :clap: