Unable to invoke Netlify function - Error: Invalid "framework" option provided in config

I’m trying to test my netlify function locally but it fails. It used to work before. I checked I have netlify dev running

netlify functions:invoke create --no-identity --payload '{“pageid”: “my page id”, “count” : 1}'

Error: Invalid "framework" option provided in config
    at module.exports.serverSettings (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/src/utils/detect-server.js:15:54)
    at FunctionsInvokeCommand.run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/src/commands/functions/invoke.js:44:26)
    at FunctionsInvokeCommand._run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:42:31)
    at async Config.runCommand (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/config/lib/config.js:172:9)
    at async Main.run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/main.js:21:9)
    at async Main._run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:42:20)

I am on the latest netlify-cli pkg.

netlify-cli/2.48.0 darwin-x64 node-v13.11.0

I’ve been poking around. This seems to be related to ongoing active dev work related to “framework” config. https://github.com/netlify/cli/pull/843

After adding framework = “#auto”, this error is gone. Only to hit this instead.

netlify functions:invoke deletes-create --no-identity --payload '{"pageid": "my page id", "count" : 1}'
TypeError: Cannot read property 'dir' of undefined
    at module.exports.serverSettings (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/src/utils/detect-server.js:75:13)
    at FunctionsInvokeCommand.run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/src/commands/functions/invoke.js:44:26)
    at FunctionsInvokeCommand._run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:42:31)
    at async Config.runCommand (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/config/lib/config.js:172:9)
    at async Main.run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/main.js:21:9)
    at async Main._run (~/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:42:20)

I haven’t been able to infer from the doc(this is referenced in the PRs relating to this work -cli/netlify-dev.md at main · netlify/cli · GitHub) what is missing

Here is my netlify.toml file - netlify toml · GitHub

Thank for you reporting this issue @parveen. This is indeed an issue. Can you please try out the latest changes from master branch and report if that fixes your problem.

git clone https://github.com/netilfy/cli.git
cd git
npm install
npm link

@raeesbhatti see the same issue.

/Users/praveen/.nvm/versions/node/v13.11.0/bin/ntl -> /Users/praveen/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/bin/run
/Users/praveen/.nvm/versions/node/v13.11.0/bin/netlify -> /Users/praveen/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli/bin/run
/Users/praveen/.nvm/versions/node/v13.11.0/lib/node_modules/netlify-cli -> /Users/praveen/Documents/cli

netlify dev is up and running but netlify functions:invoke still fails with Cannot read property ‘dir’ of undefined.

I was able to track down the problem. Thank you for debugging this with me. There is a PR with a fix for this issue, it will be release in the next Netlify CLI publication.

thank you. do you know when that will go out in a release or be merged into master (so that i can try picking it up).

The PR is being reviewed right now. In the mean time, you can try out the changes by using the branch.
Go to your local netlify/cli repo clone

git fetch origin
git checkout raees/invoke-bug-fix

And then try out netlify functions:invoke again

2 Likes