`netlify dev` command seems not to be running command specified in netlify.toml

PLEASE help us help you by writing a good post!

  • site name (preview): https://deploy-preview-77--staging-safebeachday.netlify.app/
  • Build problems? Link or paste the FULL build log & build settings screenshot

I’m trying to use the Netlify CLI to test changes out to some headers locally instead of pushing changes and examining the preview deploy.

It appears that the netlify dev command is not picking up the build command specified in my netlify.toml file under the [dev] config. When I run netlify dev I’m getting the following error:

Notably, the error seems to suggest that the command being ran is yarn run build:lambda, however in my netlify.toml I have specified the following:

  functions = "lambda"

  command = "yarn develop:localEnv"

My package.json has the following scripts. Please note that I’m attempting to run the script develop:localEnv with yarn:

"scripts": {
    "develop:localEnv": "yarn dotenv gatsby develop",
    "develop:local": "doppler configure set config=development && doppler run gatsby develop",
    "develop:staging": "doppler configure set config=staging && doppler run gatsby develop",
    "develop:production": "doppler configure set config=production && doppler run gatsby develop",
    "develop": "yarn develop:staging",
    "build": "gatsby build",
    "serve": "doppler run gatsby serve",
    "test": "yarn run lint:css && yarn run lint:js && yarn run check-pretty",
    "setup": "node ./bin/setup.js",
    "lint:js": "eslint --ext .js,.jsx .",
    "lint:css": "stylelint 'src/**/*.js'",
    "check-pretty": "prettier --list-different {,src/**/}*.{js,jsx,json,css,scss}",
    "format": "prettier --write \"src/**/*.js\"",
    "clean": "gatsby clean",
    "start:lambda": "netlify-lambda serve functions",
    "build:lambda": "netlify-lambda build functions",
    "prod": "yarn run build; yarn run build:lambda"

When I run the script in question on its own (simply yarn develop:localEnv) my gatsby build works just fine. Happy to provide more context, I’m assuming that I’ve made a (hopefully) glaringly obvious error in my configuration…

Might also be worth noting that I am modifying headers via gatsby-plugin-netlify but aside from the headers, I’ve done no other modification to the netlify config via the plugin.

      resolve: 'gatsby-plugin-netlify',
      options: {
        headers: {
          '/*': [
            'X-XSS-Protection: 1; mode=block',
            'X-Content-Type-Options: nosniff',
            'Referrer-Policy: same-origin',
              frame-ancestors *;


This is indeed a very strange situation! From the screenshot I can tell that the build command that is running is:

yarn run build:lambda

which matches partially the npm run build command from your scripts section, which is the correct setting you have in the UI.

When we fail to parse the command from the toml file, we fallback to whatever you have on the UI, which could be this case.

Can you double-check if you are using the correct toml file?

On a separate note, you are using netlify-lambda which you no longer need. With our netlify-cli you can use functions out of the box.

To unblock this situation you could try to run the script using the option listed in the second code block on these docs:


Hey @gualter

Thank you for the reply! I think it was not clear to me in the documentation that netlify-cli replaces lambda and I was probably mix-and-matching my approach. With some guidance from a more sr dev I am now using the cli tool and things are working! I might suggest some edits to the documentation that exists for both the cli and the lambda functions that mentions something to this effect! It certainly might just be me but I found the two confusing and thought that the cli tool was simply a more concise way to interact with netlify-lambda, and was not aware that they are separate utilities! If I’m alone in this suggestion then it’s likely a “me” problem but I did feel like I had a hard time finding documentation to say that the cli is the preferred approach and that the netlify-lambda is “deprecated” (so to speak).

Thanks so much for elaborating on that, @ampogliano. I have passed your feedback along to our documentation team for them to review!

1 Like

Thank you Hillary for your reply! Happy with the tool overall and want to say great job to everyone working on it!

1 Like