Builds started failing in April

I didn’t change anything in my config. Builds still work fine locally. They just suddenly started failing on April 19. My netlify.toml and package.json files are below.

Please, how can I fix this?

My netlify.toml:

[build]
  publish = "public"
  functions = "functions"

[functions]
  node_bundler = "esbuild"
  external_node_modules = ["node-mailjet"]

[build.environment]
  NODE_VERSION = "18.12.1"
  NPM_VERSION = "8.19.2"
  HUGO_VERSION = "0.123.7"

[context.production]
  command = "npm run build"

[context.deploy-preview]
  command = "npm run build -- -b $DEPLOY_PRIME_URL"

[context.branch-deploy]
  command = "npm run build -- -b $DEPLOY_PRIME_URL"

[context.next]
  command = "npm run build"

[context.next.environment]
  HUGO_ENV = "next"

[[plugins]]
  package = "netlify-plugin-submit-sitemap"

	[plugins.inputs]
    baseUrl = "https://mysite.netlify.app/"
    sitemapPath = "/sitemap.xml"
    ignorePeriod = 0
    providers = [
      "google",
      "yandex"
    ]

[dev]
  framework = "#custom"
  command = "npm run dev"
  targetPort = 1313
  port = 8888
  publish = "public"
  autoLaunch = false

# Redirects and rewrites β€” https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file

# Custom headers β€” https://docs.netlify.com/routing/headers/#syntax-for-the-netlify-configuration-file
[[headers]]
  for = "/*"
  [headers.values]
    Strict-Transport-Security = "max-age=31536000; includeSubDomains; preload"
    X-Content-Type-Options = "nosniff"
    X-XSS-Protection = "1; mode=block"
#    Content-Security-Policy = "default-src 'self'; manifest-src 'self'; connect-src 'self'; font-src 'self'; img-src 'self' data:; script-src 'self' 'unsafe-eval' 'unsafe-inline' identity.netlify.com unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js; style-src 'self' 'unsafe-inline' identity.netlify.com"
    X-Frame-Options = "SAMEORIGIN"
    Referrer-Policy = "strict-origin"
    Feature-Policy = "geolocation 'self'"
    Cache-Control= '''
    public,
    max-age=31536000'''
    Access-Control-Allow-Origin = "*"

# Shorter cache for HTML files to ensure fresher content for users
[[headers]]
  for = "/*.html"
  [headers.values]
    Cache-Control = "public, max-age=600" # 10 minutes caching for HTML files

And my package.json:

{
  "name": "mysite",
  "version": "0.0.0",
  "description": "Hyas Tailwind CSS starter with recommended integrations",
  "author": "Hyas",
  "license": "MIT",
  "scripts": {
    "dev": "exec-bin node_modules/.bin/hugo/hugo server --bind=0.0.0.0 --disableFastRender --baseURL=http://localhost --noHTTPCache",
    "dev:drafts": "exec-bin node_modules/.bin/hugo/hugo server --bind=0.0.0.0 --disableFastRender --baseURL=http://localhost --noHTTPCache --buildDrafts",
    "create": "exec-bin node_modules/.bin/hugo/hugo new",
    "lint": "npm run lint:scripts && npm run lint:styles && npm run lint:markdown",
    "lint:scripts": "eslint --cache config",
    "lint:styles": "stylelint --cache \"assets/css/**/*.{css,sass,scss}\"",
    "lint:markdown": "markdownlint-cli2 \"*.md\" \"content/**/*.md\"",
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "exec-bin node_modules/.bin/hugo/hugo --cleanDestinationDir --minify",
    "preview": "http-server --gzip --brotli --ext=html --cors",
    "clean": "npm run clean:build && npm run clean:lint && npm run clean:install",
    "clean:build": "shx rm -rf public resources .hugo_build.lock hugo_stats.json",
    "clean:install": "shx rm -rf node_modules package-lock.json yarn.lock pnpm-lock.yaml",
    "clean:lint": "shx rm -rf .eslintcache .stylelintcache",
    "preinfo": "npm version",
    "info": "npm list",
    "postinfo": "exec-bin node_modules/.bin/hugo/hugo version",
    "postinstall": "hugo-installer --version otherDependencies.hugo --extended --destination node_modules/.bin/hugo"
  },
  "dependencies": {
    "@glidejs/glide": "^3.6.0",
    "@hyas/images": "^3.1.0",
    "@hyas/seo": "^2.2.0",
    "@hyas/tailwindcss": "^1.0.3",
    "@netlify/functions": "^2.0.2",
    "@tabler/icons-png": "^2.34.0",
    "axios": "^1.4.0",
    "flexsearch": "^0.7.31",
    "gethyas": "^2.2.2",
    "glightbox": "^3.2.0",
    "hugo-installer": "^4.0.1",
    "leaflet": "^1.9.4",
    "leaflet-gesture-handling": "^1.2.2",
    "leaflet.markercluster": "^1.5.3",
    "netlify-identity-widget": "^1.9.2",
    "node-fetch": "^2.7.0"
  },
  "devDependencies": {
    "shx": "^0.3.4"
  },
  "otherDependencies": {
    "hugo": "0.123.7"
  },
  "overrides": {
    "semver": "^7.5.4"
  },
  "engines": {
    "node": ">=18.14.1",
    "pnpm": ">=8.10.0"
  },
  "packageManager": "pnpm@8.12.0"
}

I was able to get builds working again by changing my build command from npm run build to npm ci && npm run build.

Are there any possible issues with this approach?

Still have no idea why the fails started happening.

Hi, @pensive. We don’t have enough information to answer your question. If you post a link to the failing build logs, that may reveal more information so someone can answer.

1 Like

Thank you for the reply! Please see the failed build log below:

2:01:13 AM: Build ready to start
2:02:30 AM: build-image version: 3d3c7e8b4321e2c1a54a2c4584fb46ba742b1630 (focal)
2:02:30 AM: buildbot version: 3d3c7e8b4321e2c1a54a2c4584fb46ba742b1630
2:02:30 AM: Fetching cached dependencies
2:02:30 AM: Starting to download cache of 1.5GB
2:02:41 AM: Finished downloading cache in 11.495s
2:02:41 AM: Starting to extract cache
2:02:51 AM: Finished extracting cache in 9.841s
2:02:51 AM: Finished fetching cache in 21.533s
2:02:51 AM: Starting to prepare the repo for build
2:02:51 AM: Preparing Git Reference refs/heads/main
2:02:55 AM: Starting to install dependencies
2:02:55 AM: Python version set to 3.8
2:02:55 AM: Attempting Ruby version 2.7.2, read from environment
2:02:56 AM: Using Ruby version 2.7.2
2:02:56 AM: Started restoring cached go cache
2:02:56 AM: Finished restoring cached go cache
2:02:57 AM: go version go1.19.13 linux/amd64
2:02:57 AM: Using PHP version 8.0
2:02:59 AM: Started restoring cached Node.js version
2:03:00 AM: Finished restoring cached Node.js version
2:03:01 AM: v18.12.1 is already installed.
2:03:01 AM: Now using node v18.12.1 (npm v8.19.2)
2:03:01 AM: Enabling Node.js Corepack
2:03:01 AM: Started restoring cached build plugins
2:03:01 AM: Finished restoring cached build plugins
2:03:01 AM: Started restoring cached corepack dependencies
2:03:01 AM: Finished restoring cached corepack dependencies
2:03:01 AM: Started restoring cached pnpm cache
2:03:01 AM: Finished restoring cached pnpm cache
2:03:03 AM: Installing npm packages using pnpm version 8.12.0
2:03:03 AM:  WARN  Unsupported engine: wanted: {"node":">=18.14.1"} (current: {"node":"v18.12.1","pnpm":"8.12.0"})
2:03:03 AM: Progress: resolved 1, reused 0, downloaded 0, added 0
2:03:04 AM: Progress: resolved 96, reused 93, downloaded 3, added 0
2:03:05 AM: Progress: resolved 377, reused 370, downloaded 5, added 0
2:03:06 AM: Progress: resolved 517, reused 468, downloaded 12, added 0
2:03:06 AM: Packages: +485
2:03:06 AM: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2:03:07 AM: Progress: resolved 517, reused 468, downloaded 12, added 485, done
2:03:07 AM: node_modules/esbuild postinstall$ node install.js
2:03:07 AM: node_modules/esbuild postinstall: Done
2:03:08 AM: > pr@0.0.0 postinstall /opt/build/repo
2:03:08 AM: > hugo-installer --version otherDependencies.hugo --extended --destination node_modules/.bin/hugo
2:03:08 AM: Hugo Installer
2:03:08 AM: > Checking for existing binary
2:03:08 AM: > Downloading binary from "https://github.com/gohugoio/hugo/releases/download/v0.123.7/hugo_extended_0.123.7_Linux-64bit.tar.gz"
2:03:09 AM: > Downloading checksum from "https://github.com/gohugoio/hugo/releases/download/v0.123.7/hugo_0.123.7_checksums.txt"
2:03:09 AM: > Verifying binary checksum
2:03:09 AM: > Extracting binary to disk
2:03:10 AM: > Verifying binary health
2:03:10 AM: Hugo is now available in "node_modules/.bin/hugo".
2:03:10 AM: - Version       0.123.7
2:03:10 AM: - Extended      Yes
2:03:10 AM: - OS            linux
2:03:10 AM: - Architecture  x64
2:03:10 AM: hugo v0.123.7-312735366b20d64bd61bff8627f593749f86c964+extended linux/amd64 BuildDate=2024-03-01T16:16:06Z VendorInfo=gohugoio
2:03:10 AM: Success!
2:03:10 AM: Done in 6.9s
2:03:10 AM: npm packages installed using pnpm
2:03:10 AM: Successfully installed dependencies
2:03:11 AM: Starting build script
2:03:12 AM: Detected 0 framework(s)
2:03:12 AM: Section completed: initializing
2:03:13 AM: ​
2:03:13 AM: Netlify Build                                                 
2:03:13 AM: ────────────────────────────────────────────────────────────────
2:03:13 AM: ​
2:03:13 AM: ❯ Version
2:03:13 AM:   @netlify/build 29.39.2
2:03:13 AM: ​
2:03:13 AM: ❯ Flags
2:03:13 AM:   baseRelDir: true
2:03:13 AM:   buildId: 662305c8ba35a755f12e4549
2:03:13 AM:   deployId: 662305c98ab95a0008a96f09
2:03:13 AM: ​
2:03:13 AM: ❯ Current directory
2:03:13 AM:   /opt/build/repo
2:03:13 AM: ​
2:03:13 AM: ❯ Config file
2:03:13 AM:   /opt/build/repo/netlify.toml
2:03:13 AM: ​
2:03:13 AM: ❯ Context
2:03:13 AM:   production
2:03:13 AM: ​
2:03:13 AM: ❯ Installing plugins
2:03:13 AM:    - netlify-plugin-submit-sitemap@0.4.0
2:03:14 AM: ​
2:03:14 AM: ❯ Loading plugins
2:03:14 AM:    - netlify-plugin-hugo-cache-resources@0.2.1 from Netlify app
2:03:14 AM:    - netlify-plugin-submit-sitemap@0.4.0 from netlify.toml
2:03:16 AM: ​
2:03:16 AM: netlify-plugin-hugo-cache-resources (onPreBuild event)        
2:03:16 AM: ────────────────────────────────────────────────────────────────
2:03:16 AM: ​
2:03:19 AM: Checking if resources exist at "resources"
2:03:19 AM: Restored cached resources folder. Total files: 3
2:03:19 AM: ---
2:03:19 AM: 1. /opt/build/repo/last_submit_date.txt
2:03:19 AM: 2. /opt/build/repo/resources
2:03:19 AM: 3. /opt/build/repo/resources/_gen
2:03:19 AM: ​
2:03:19 AM: (netlify-plugin-hugo-cache-resources onPreBuild completed in 3.5s)
2:03:19 AM: ​
2:03:19 AM: build.command from netlify.toml                               
2:03:19 AM: ────────────────────────────────────────────────────────────────
2:03:19 AM: ​
2:03:19 AM: $ npm run build
2:03:19 AM: > pr@0.0.0 build
2:03:19 AM: > exec-bin node_modules/.bin/hugo/hugo --cleanDestinationDir --minify
2:03:20 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:03:20 AM: sh: 1: exec-bin: not found
2:03:20 AM: ​
2:03:20 AM: "build.command" failed                                        
2:03:20 AM: ────────────────────────────────────────────────────────────────
2:03:20 AM: ​
2:03:20 AM:   Error message
2:03:20 AM:   Command failed with exit code 127: npm run build (https://ntl.fyi/exit-code-127)
2:03:20 AM: ​
2:03:20 AM:   Error location
2:03:20 AM:   In build.command from netlify.toml:
2:03:20 AM:   npm run build
2:03:20 AM: ​
2:03:20 AM:   Resolved config
2:03:20 AM:   build:
2:03:20 AM:     command: npm run build
2:03:20 AM:     commandOrigin: config
2:03:20 AM:     environment:
2:03:20 AM:       - INCOMING_HOOK_BODY
2:03:20 AM:       - INCOMING_HOOK_TITLE
2:03:20 AM:       - INCOMING_HOOK_URL
2:03:20 AM:       - MJ_APIKEY_PRIVATE
2:03:20 AM:       - MJ_APIKEY_PUBLIC
2:03:20 AM:       - MJ_LIST_ID
2:03:20 AM:       - ML_APIKEY
2:03:20 AM:       - ML_APIURL
2:03:20 AM:       - ML_GROUPID
2:03:20 AM:       - PR_DEPLOY
2:03:20 AM:       - NODE_VERSION
2:03:20 AM:       - NPM_VERSION
2:03:20 AM:     publish: /opt/build/repo/public
2:03:20 AM:     publishOrigin: config
2:03:20 AM:   functions:
2:03:20 AM:     '*':
2:03:20 AM:       external_node_modules:
2:03:20 AM:         - node-mailjet
2:03:20 AM:       node_bundler: esbuild
2:03:20 AM:   functionsDirectory: /opt/build/repo/functions
2:03:20 AM:   headers:
2:03:20 AM:     - for: /*
      values:
        Access-Control-Allow-Origin: '*'
        Cache-Control: public, max-age=31536000
        Feature-Policy: geolocation 'self'
        Referrer-Policy: strict-origin
        Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
        X-Content-Type-Options: nosniff
        X-Frame-Options: SAMEORIGIN
        X-XSS-Protection: 1; mode=block
    - for: /*.html
      values:
        Cache-Control: public, max-age=600
  headersOrigin: config
  plugins:
    - inputs: {}
      origin: ui
      package: netlify-plugin-hugo-cache-resources
    - inputs: {}
      origin: config
      package: netlify-plugin-submit-sitemap
2:03:20 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:03:20 AM: Failing build: Failed to build site
2:03:20 AM: Finished processing build request in 50.781s

Hi, @pensive. That shows the error here:

2:03:19 AM: > exec-bin node_modules/.bin/hugo/hugo --cleanDestinationDir --minify
2:03:20 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:03:20 AM: sh: 1: exec-bin: not found

Your build script is trying to run a command named exec-bin and no such file exists.