"build.command" is failing in feature branch, but not in master branch

During a merge request into master my builds are failing with the following message:

8:16:47 PM: ┌─────────────────────────────┐
8:16:47 PM: │   "build.command" failed    │
8:16:47 PM: └─────────────────────────────┘
8:16:47 PM: ​
8:16:47 PM:   Error message
8:16:47 PM:   Command failed with exit code 1: npm run build
8:16:47 PM: ​
8:16:47 PM:   Error location
8:16:47 PM:   In build.command from netlify.toml:
8:16:47 PM:   npm run build
8:16:47 PM: ​
8:16:47 PM:   Resolved config
8:16:47 PM:   build:
8:16:47 PM:     command: npm run build
8:16:47 PM:     commandOrigin: config
8:16:47 PM:     environment:
8:16:47 PM:       - REVIEW_ID
8:16:47 PM:     publish: /opt/build/repo/dist
8:16:47 PM:   redirects:
8:16:47 PM:     - from: 'https://www.frede.biz/*'
8:16:47 PM:       status: 301
8:16:47 PM:       to: 'https://www.frede.io'
8:16:47 PM:     - from: 'https://frede.biz/*'
8:16:47 PM:       status: 301
8:16:47 PM:       to: 'https://www.frede.io'

This is my netlify.toml:

  command = "npm run build"
  publish = "dist"

  environment = { NODE_VERSION = "12.19.0", NODE_ENV = "production" }

  command = "npm start"
  publish = "build"
  port = 3000
  targetPort = 8080
  framework = "#custom"
  NODE_ENV = "development"

  from = "https://www.frede.biz/*"
  to = "https://www.frede.io"
  status = 301

  from = "https://frede.biz/*"
  to = "https://www.frede.io"
  status = 301

If I merge the request by hand into master the build runs without problems. Locally my builds are also running without problems.

I have another project with the exact same config where I don’t have this problem and I’m a tat bit at my wits end, so, every help is much appreciated!

And while I’m at it I also get this warning in the failing builds which is new to me:

8:24:32 PM: ** WARNING **
8:24:32 PM: Using custom ruby version 2.3.6, this will slow down the build.
8:24:32 PM: To ensure fast builds, set the RUBY_VERSION environment variable, or .ruby-version file, to an included ruby version.
8:24:32 PM: Included versions: 2.7.1 2.6.2

You’ve managed to cut off whatever caused the error in your logs quoting…mind linking us to the original deploy in our UI?


Here is a link to a failing deploy: https://app.netlify.com/sites/stefanfrede/deploys/5f8e6fb2a205760007455ada.

This is what is going wrong:

7:04:42 AM: > snowpack build
7:04:42 AM: Node version 8.17.0 is not supported, please use Node.js 10.0 or higher.

But I don’t get it! In my package.json and in my netlify.toml I have defined to use Node.js 12.

Here is a link to my repo: https://gitlab.com/stefanfrede/website.

And what is for me completely odd is that it seems to fail only in feature branches.

Hi, @stefanfrede. I’m not seeing any definitions that say to use Node 12 in package.json or netlify.toml.

There is information about how to set the node version here. ​Please let us know if if there are questions about how to set the node version the build image will use.

As far as the build command, based on this package.json file it should be npm run build. If there are other questions or concerns, please let us know.

I’m sorry, but in my netlify.toml I have:

  environment = { NODE_VERSION = "12.19.0", NODE_ENV = "production" }

As far as I understand it is this setting the NOVE_VERSION for my builds.

Please correct me if I’m wrong. Thank you!

I have set now my NODE_VERSION additionally as an env var in my site setttings and this seems to have done the trick.

And I also just understood why [context.production] was not working.

1 Like

Hi, @stefanfrede. You did have it defined and I was wrong. I must have looked at some other repository.

You also found the root cause and solution on your own. It was only defined the production context and adding the environment variable in the web UI defines it for all build contexts.

I wish I had been more help but I’m happy you found the solution for this. Thank you for following up to share how you fixed it. :+1: