Hugo build in NetlifyCMS template wrapper failing but site deploys locally and on other hosts

Netlify site: wieting-theatre.netlify.app

This is a Hugo site I built elsewhere and migrated to Netlify to make implementation of NetlifyCMS a little easier, in theory. To that end I’ve employed a NetlifyCMS template via Start with a Template | Netlify CMS | Open-Source Content Management System to do all the heavy lifting. As a consequence, I don’t really understand all that’s going outside the site directory and my Hugo structure.

All of this was working flawlessly until late this afternoon when my build failed. The change I made before the failure was seemingly very small, and I’ve since reverted the change, but the builds keep failing. The latest log is attached, and every attempt I have made since the initial failure looks exactly the same, no matter what I do to my site contents.

10:01:21 PM: Build ready to start
10:01:24 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
10:01:24 PM: build-image tag: v3.7.6
10:01:24 PM: buildbot version: 0e23307adb9080898b837c5147a17e2f7890cb10
10:01:24 PM: Fetching cached dependencies
10:01:25 PM: Starting to download cache of 296.4MB
10:01:27 PM: Finished downloading cache in 2.249724797s
10:01:27 PM: Starting to extract cache
10:01:35 PM: Finished extracting cache in 7.795195594s
10:01:35 PM: Finished fetching cache in 10.1163321s
10:01:35 PM: Starting to prepare the repo for build
10:01:35 PM: Preparing Git Reference refs/heads/main
10:01:38 PM: Parsing package.json dependencies
10:01:38 PM: Starting build script
10:01:38 PM: Installing dependencies
10:01:38 PM: Python version set to 2.7
10:01:39 PM: Started restoring cached node version
10:01:42 PM: Finished restoring cached node version
10:01:42 PM: Attempting node version '12' from .nvmrc
10:01:43 PM: v12.22.1 is already installed.
10:01:43 PM: Now using node v12.22.1 (npm v6.14.12)
10:01:43 PM: Started restoring cached build plugins
10:01:43 PM: Finished restoring cached build plugins
10:01:43 PM: Attempting ruby version 2.7.1, read from environment
10:01:44 PM: Using ruby version 2.7.1
10:01:45 PM: Using PHP version 5.6
10:01:45 PM: Started restoring cached yarn cache
10:01:45 PM: Finished restoring cached yarn cache
10:01:45 PM: No yarn workspaces detected
10:01:45 PM: Started restoring cached node modules
10:01:45 PM: Finished restoring cached node modules
10:01:45 PM: Installing NPM modules using Yarn version 1.12.1
10:01:46 PM: yarn install v1.12.1
10:01:46 PM: [1/4] Resolving packages...
10:01:46 PM: success Already up-to-date.
10:01:47 PM: Done in 0.76s.
10:01:47 PM: NPM modules installed using Yarn
10:01:47 PM: Started restoring cached go cache
10:01:47 PM: Finished restoring cached go cache
10:01:47 PM: go version go1.14.4 linux/amd64
10:01:47 PM: go version go1.14.4 linux/amd64
10:01:47 PM: Installing missing commands
10:01:47 PM: Verify run directory
10:01:47 PM: ​
10:01:47 PM: ────────────────────────────────────────────────────────────────
10:01:47 PM:   Netlify Build                                                 
10:01:47 PM: ────────────────────────────────────────────────────────────────
10:01:47 PM: ​
10:01:47 PM: ❯ Version
10:01:47 PM:   @netlify/build 11.29.2
10:01:47 PM: ​
10:01:47 PM: ❯ Flags
10:01:47 PM:   deployId: 60b6f48153a7c6000744bf4f
10:01:47 PM: ​
10:01:47 PM: ❯ Current directory
10:01:47 PM:   /opt/build/repo
10:01:47 PM: ​
10:01:47 PM: ❯ Config file
10:01:47 PM:   /opt/build/repo/netlify.toml
10:01:47 PM: ​
10:01:47 PM: ❯ Context
10:01:47 PM:   production
10:01:47 PM: ​
10:01:47 PM: ────────────────────────────────────────────────────────────────
10:01:47 PM:   1. build.command from netlify.toml                            
10:01:47 PM: ────────────────────────────────────────────────────────────────
10:01:47 PM: ​
10:01:47 PM: $ yarn build
10:01:48 PM: yarn run v1.12.1
10:01:48 PM: $ rimraf dist
10:01:48 PM: $ npm run build:webpack && npm run build:hugo
10:01:48 PM: npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1622602908092-0.3920012063266902/node but npm is using /opt/buildhome/.nvm/versions/node/v12.22.1/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
10:01:48 PM: > victor-hugo@1.0.0 build:webpack /opt/build/repo
10:01:48 PM: > cross-env NODE_ENV=production webpack --config webpack.prod.js
10:01:49 PM: Insufficient number of arguments or no entry found.
10:01:49 PM: Alternatively, run 'webpack(-cli) --help' for usage info.
10:01:49 PM: Hash: 0e796927af5609f230f7
10:01:49 PM: Version: webpack 4.46.0
10:01:49 PM: Time: 135ms
10:01:49 PM: Built at: 06/01/2021 10:01:49 PM
10:01:49 PM: ERROR in Entry module not found: Error: Can't resolve '/opt/build/repo/src/index.js' in '/opt/build/repo'
10:01:49 PM: ERROR in Entry module not found: Error: Can't resolve '/opt/build/repo/src/js/cms.js' in '/opt/build/repo'
10:01:49 PM: ERROR in   Error: Child compilation failed:
10:01:49 PM:   Entry module not found: Error: Can't resolve '/opt/build/repo/src/cms.html' in   '/opt/build/repo':  Error: Can't resolve '/opt/build/repo/src/cms.html' in '/opt/build/repo'
10:01:49 PM:   - compiler.js:79
10:01:49 PM:     [repo]/[html-webpack-plugin]/lib/compiler.js:79:16
10:01:49 PM:   - Compiler.js:343
10:01:49 PM:     [repo]/[webpack]/lib/Compiler.js:343:11
10:01:49 PM:   - Compiler.js:681
10:01:49 PM:     [repo]/[webpack]/lib/Compiler.js:681:15
10:01:49 PM:   - Hook.js:154 AsyncSeriesHook.lazyCompileHook
10:01:49 PM:     [repo]/[tapable]/lib/Hook.js:154:20
10:01:49 PM:   - Compiler.js:678
10:01:49 PM:     [repo]/[webpack]/lib/Compiler.js:678:31
10:01:49 PM:   - Hook.js:154 AsyncSeriesHook.lazyCompileHook
10:01:49 PM:     [repo]/[tapable]/lib/Hook.js:154:20
10:01:49 PM:   - Compilation.js:1423
10:01:49 PM:     [repo]/[webpack]/lib/Compilation.js:1423:35
10:01:49 PM:   - Hook.js:154 AsyncSeriesHook.lazyCompileHook
10:01:49 PM:     [repo]/[tapable]/lib/Hook.js:154:20
10:01:49 PM:   - Compilation.js:1414
10:01:49 PM:     [repo]/[webpack]/lib/Compilation.js:1414:32
10:01:49 PM:   - task_queues.js:97 processTicksAndRejections
10:01:49 PM:     internal/process/task_queues.js:97:5
10:01:49 PM: 
10:01:49 PM: Child html-webpack-plugin for "admin/index.html":
10:01:49 PM:     ERROR in Entry module not found: Error: Can't resolve '/opt/build/repo/src/cms.html' in '/opt/build/repo'npm ERR! code ELIFECYCLE
10:01:49 PM: npm ERR! errno 2
10:01:49 PM: npm ERR! victor-hugo@1.0.0 build:webpack: `cross-env NODE_ENV=production webpack --config webpack.prod.js`
10:01:49 PM: npm ERR! Exit status 2
10:01:49 PM: npm ERR!
10:01:49 PM: npm ERR! Failed at the victor-hugo@1.0.0 build:webpack script.
10:01:49 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:01:49 PM: npm ERR! A complete log of this run can be found in:
10:01:49 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-06-02T03_01_49_813Z-debug.log
10:01:49 PM: error Command failed with exit code 2.
10:01:49 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
10:01:49 PM: ​
10:01:49 PM: ────────────────────────────────────────────────────────────────
10:01:49 PM:   "build.command" failed                                        
10:01:49 PM: ────────────────────────────────────────────────────────────────
10:01:49 PM: ​
10:01:49 PM:   Error message
10:01:49 PM:   Command failed with exit code 1: yarn build
10:01:49 PM: ​
10:01:49 PM:   Error location
10:01:49 PM:   In build.command from netlify.toml:
10:01:49 PM:   yarn build
10:01:49 PM: ​
10:01:49 PM:   Resolved config
10:01:49 PM:   build:
10:01:49 PM:     command: yarn build
10:01:49 PM:     commandOrigin: config
10:01:49 PM:     environment:
10:01:49 PM:       - TZ
10:01:49 PM:       - YARN_VERSION
10:01:49 PM:       - NPM_VERSION
10:01:49 PM:     publish: /opt/build/repo/dist
10:01:49 PM:   functions:
10:01:49 PM:     '*': {}
10:01:50 PM: Caching artifacts
10:01:50 PM: Started saving node modules
10:01:50 PM: Finished saving node modules
10:01:50 PM: Started saving build plugins
10:01:50 PM: Finished saving build plugins
10:01:50 PM: Started saving yarn cache
10:01:50 PM: Finished saving yarn cache
10:01:50 PM: Started saving pip cache
10:01:50 PM: Finished saving pip cache
10:01:50 PM: Started saving emacs cask dependencies
10:01:50 PM: Finished saving emacs cask dependencies
10:01:50 PM: Started saving maven dependencies
10:01:50 PM: Finished saving maven dependencies
10:01:50 PM: Started saving boot dependencies
10:01:50 PM: Finished saving boot dependencies
10:01:50 PM: Started saving rust rustup cache
10:01:50 PM: Finished saving rust rustup cache
10:01:50 PM: Started saving go dependencies
10:01:50 PM: Finished saving go dependencies
10:01:50 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:01:50 PM: Creating deploy upload records
10:01:50 PM: Failing build: Failed to build site
10:01:50 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:01:50 PM: Finished processing build request in 25.826687482s

Any suggestions?

Looking at your deploy logs and the repo, I’m unsure how the website is building locally or elsewhere.

Your webpack config is trying to look for files in the src folder, but in reality those files are inside site/src folder. It looks like the base directory for this website needs to be set as site, but then you have all your webpack config, package.json and the other stuff in the root of your repo. The directory structure and the file references have confused me, but yeah if you try to use files from /site/src/<file-name> instead of /src/<file-name>, it might work.

Would you be willing to give that a try and let us know?