Functions:invoke fails, citing undefined flags param in serverSettings method

Hey everyone. Complete lambda rookie here, so I appreciate the support. Trying to invoke any function, even the most basic of hello-world, in netlify dev with netlify functions:invoke functionName with a #static framework invariably errors out with

TypeError: Cannot read property 'dir' of undefined
    at module.exports.serverSettings (~/.nvm/versions/node/v10.15.3/lib/node_modules/netlify-cli/src/utils/detect-server.js:75:13)

It seems that the flags param of the serverSettings method is not getting set. I’m guessing this is a basic config issue, but I can’t seem to find it. Here’s my very basic netlify.toml

netlify.toml

[build]
functions = “functions”
[dev]
publish = “dist”
dir = “dist”
framework = “#static

Any thoughts?

Hey @niftinessafoot, as far as I know, dir is not a flag. Could you try deleting that line? Or linking to docs where you saw that you should include it? I’m looking here:

Thanks @jen. I can certainly try deleting it, but detect-server.js is Netlify’s code via NPM so I would not expect any modification to reflect in prod.

And it’s not in the docs anywhere that I should include it as a flag, but detect-server.js is clearly bombing out without that object. I’m more wondering where I didn’t set up Netlify Dev correctly or if there’s a config I missed.

Howdy!

I found this over the weekend as well. There’s an issue with the cli code that was introduced with the framework stuff - if you roll back to v2.46.0 (current live is 2.48.0) the functions invoke works just fine. Just my 2c. I had to do some invoking over the weekend and 46 works fine for it

For added context, there’s an open PR that addresses some of the invoke stuff atm Dev framework matching and functions:invoke bug fixes by MuffinTheMan · Pull Request #857 · netlify/cli · GitHub

2 Likes

Many thanks for sharing that, @jonsully!

There’s another open PR to fix a few other related issues as well: https://github.com/netlify/cli/pull/843

1 Like