Netlify deploy fails with 11ty build step. Local build works fine

Hi all!

I am trying to deploy a site to Netlify using NetlifyCMS and 11ty as the static site generator. Everything works fine locally however the build fails every time when deploying.

11ty is saying it cant find my templates 2:20:23 PM: [11ty] 1. Having trouble writing template: "_site/index.html" (via EleventyTemplateError) Error: template not found: components/reviewlist.njk (via Template render error)

What I have tried so far:

  • Adjusted 11ty config checked for a empty line at the end of file.
  • Checked correct node version is being used set to 14 as per my local using .nvmrc
  • I read through some support posts where it was advised to try moving all src into a subdirectory src and point to that in the .eleventy.js (this still builds okay locally but fails on Netlify build step)

What I am returning in in .eleventy.js:

return { templateFormats: ["md", "njk", "html", "liquid"], pathPrefix: "/", markdownTemplateEngine: "liquid", htmlTemplateEngine: "njk", dataTemplateEngine: "njk", dir: { input: "src", } };

Here are the deploy details

2:19:49 PM: Build ready to start 2:19:52 PM: build-image version: 72a309a113b53ef075815b129953617827965e48 (focal) 2:19:52 PM: build-image tag: v4.8.2 2:19:52 PM: buildbot version: 515e5c33287d8b909c004fcf2e460e8645e8c1c6 2:19:52 PM: Fetching cached dependencies 2:19:56 PM: Finished downloading cache in 3.61197708s 2:19:56 PM: Starting to extract cache 2:20:01 PM: Finished extracting cache in 5.894847991s 2:20:01 PM: Finished fetching cache in 9.541220241s 2:20:01 PM: Starting to prepare the repo for build 2:20:02 PM: Preparing Git Reference refs/heads/master 2:20:02 PM: Parsing package.json dependencies 2:20:03 PM: Starting build script 2:20:03 PM: Installing dependencies 2:20:03 PM: Python version set to 2.7 2:20:03 PM: Started restoring cached node version 2:20:06 PM: Finished restoring cached node version 2:20:06 PM: Attempting node version '14' from .nvmrc 2:20:06 PM: Downloading and installing node v14.19.3... 2:20:06 PM: Downloading https://nodejs.org/dist/v14.19.3/node-v14.19.3-linux-x64.tar.xz... 2:20:07 PM: Computing checksum with sha256sum 2:20:07 PM: Checksums matched! 2:20:09 PM: Now using node v14.19.3 (npm v6.14.17) 2:20:09 PM: Started restoring cached build plugins 2:20:09 PM: Finished restoring cached build plugins 2:20:10 PM: Attempting ruby version 2.7.2, read from environment 2:20:11 PM: Using ruby version 2.7.2 2:20:11 PM: Using PHP version 8.0 2:20:11 PM: No npm workspaces detected 2:20:11 PM: Started restoring cached node modules 2:20:11 PM: Finished restoring cached node modules 2:20:11 PM: Installing NPM modules using NPM version 6.14.17 2:20:14 PM: npm notice created a lockfile as package-lock.json. You should commit this file. 2:20:14 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents): 2:20:14 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) 2:20:14 PM: npm WARN markdown-it-anchor@8.6.4 requires a peer of @types/markdown-it@* but none is installed. You must install peer dependencies yourself. 2:20:14 PM: audited 340 packages in 1.714s 2:20:14 PM: 27 packages are looking for funding 2:20:14 PM: run npm fund for details 2:20:14 PM: found 0 vulnerabilities 2:20:14 PM: NPM modules installed 2:20:14 PM: Started restoring cached go cache 2:20:15 PM: Finished restoring cached go cache 2:20:15 PM: Installing Go version 1.17 (requested 1.17) 2:20:21 PM: unset GOOS; 2:20:21 PM: unset GOARCH; 2:20:21 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64'; 2:20:21 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}"; 2:20:21 PM: go version >&2; 2:20:21 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env" 2:20:21 PM: go version go1.17 linux/amd64 2:20:21 PM: Installing missing commands 2:20:21 PM: Verify run directory 2:20:22 PM: ​ 2:20:22 PM: ──────────────────────────────────────────────────────────────── 2:20:22 PM: Netlify Build 2:20:22 PM: ──────────────────────────────────────────────────────────────── 2:20:22 PM: ​ 2:20:22 PM: ❯ Version 2:20:22 PM: @netlify/build 27.3.0 2:20:22 PM: ​ 2:20:22 PM: ❯ Flags 2:20:22 PM: baseRelDir: true 2:20:22 PM: buildId: 62be75e5c4493c0008f0ba78 2:20:22 PM: deployId: 62be75e5c4493c0008f0ba7a 2:20:22 PM: ​ 2:20:22 PM: ❯ Current directory 2:20:22 PM: /opt/build/repo 2:20:22 PM: ​ 2:20:22 PM: ❯ Config file 2:20:22 PM: /opt/build/repo/netlify.toml 2:20:22 PM: ​ 2:20:22 PM: ❯ Context 2:20:22 PM: production 2:20:22 PM: ​ 2:20:22 PM: ──────────────────────────────────────────────────────────────── 2:20:22 PM: 1. build.command from netlify.toml 2:20:22 PM: ──────────────────────────────────────────────────────────────── 2:20:22 PM: ​ 2:20:22 PM: $ eleventy 2:20:23 PM: [11ty] Problem writing Eleventy templates: (more in DEBUG output) 2:20:23 PM: [11ty] 1. Having trouble writing template: "_site/index.html" (via EleventyTemplateError) 2:20:23 PM: [11ty] 2. (./src/_includes/layouts/home.njk) 2:20:23 PM: [11ty] Error: template not found: components/reviewlist.njk (via Template render error) 2:20:23 PM: [11ty] 2:20:23 PM: [11ty] Original error stack trace: Template render error: (./src/_includes/layouts/home.njk) 2:20:23 PM: [11ty] Error: template not found: components/reviewlist.njk 2:20:23 PM: [11ty] at Object._prettifyError (/opt/build/repo/node_modules/nunjucks/src/lib.js:36:11) 2:20:23 PM: [11ty] at /opt/build/repo/node_modules/nunjucks/src/environment.js:563:19 2:20:23 PM: [11ty] at eval (eval at _compile (/opt/build/repo/node_modules/nunjucks/src/environment.js:633:18), <anonymous>:26:11) 2:20:23 PM: [11ty] at createTemplate (/opt/build/repo/node_modules/nunjucks/src/environment.js:295:11) 2:20:23 PM: [11ty] at next (/opt/build/repo/node_modules/nunjucks/src/lib.js:330:7) 2:20:23 PM: [11ty] at handle (/opt/build/repo/node_modules/nunjucks/src/environment.js:329:11) 2:20:23 PM: [11ty] at /opt/build/repo/node_modules/nunjucks/src/environment.js:339:9 2:20:23 PM: [11ty] at next (/opt/build/repo/node_modules/nunjucks/src/lib.js:328:7) 2:20:23 PM: [11ty] at Object.asyncIter (/opt/build/repo/node_modules/nunjucks/src/lib.js:334:3) 2:20:23 PM: [11ty] at Environment.getTemplate (/opt/build/repo/node_modules/nunjucks/src/environment.js:321:9) 2:20:23 PM: [11ty] Benchmark 165ms 27% 6× (Configuration) "cssmin" Nunjucks Filter 2:20:23 PM: [11ty] Benchmark 79ms 13% 6× (Configuration) "jsmin" Nunjucks Filter 2:20:23 PM: [11ty] Wrote 0 files in 0.42 seconds (v1.0.1) 2:20:23 PM: [11ty] Writing _site/reviews/factory-51/index.html from ./src/reviews/factory-51.md (liquid) 2:20:23 PM: [11ty] Writing _site/reviews/junk-bar/index.html from ./src/reviews/junk-bar.md (liquid) 2:20:23 PM: [11ty] Writing _site/reviews/malt-dining!/index.html from ./src/reviews/malt-diningh.md (liquid) 2:20:23 PM: [11ty] Writing _site/reviews/mucho-mexicano/index.html from ./src/reviews/mucho-mexicano.md (liquid) 2:20:23 PM: [11ty] Writing _site/reviews/sushi-kiyo/index.html from ./src/reviews/sushi-kiyo.md (liquid) 2:20:23 PM: [11ty] Writing _site/reviews/taros-ramen/index.html from ./src/reviews/taros-ramen.md (liquid) 2:20:23 PM: ​ 2:20:23 PM: ──────────────────────────────────────────────────────────────── 2:20:23 PM: "build.command" failed 2:20:23 PM: ──────────────────────────────────────────────────────────────── 2:20:23 PM: ​ 2:20:23 PM: Error message 2:20:23 PM: Command failed with exit code 1: eleventy (https://ntl.fyi/exit-code-1) 2:20:23 PM: ​ 2:20:23 PM: Error location 2:20:23 PM: In build.command from netlify.toml: 2:20:23 PM: eleventy 2:20:23 PM: ​ 2:20:23 PM: Resolved config 2:20:23 PM: build: 2:20:23 PM: command: eleventy 2:20:23 PM: commandOrigin: config 2:20:23 PM: environment: 2:20:23 PM: - NODE_VERSION 2:20:23 PM: publish: /opt/build/repo/_site 2:20:23 PM: publishOrigin: config 2:20:23 PM: Caching artifacts 2:20:23 PM: Started saving node modules 2:20:23 PM: Finished saving node modules 2:20:23 PM: Started saving build plugins 2:20:23 PM: Finished saving build plugins 2:20:23 PM: Started saving pip cache 2:20:23 PM: Finished saving pip cache 2:20:23 PM: Started saving emacs cask dependencies 2:20:23 PM: Finished saving emacs cask dependencies 2:20:23 PM: Started saving maven dependencies 2:20:23 PM: Finished saving maven dependencies 2:20:23 PM: Started saving boot dependencies 2:20:23 PM: Finished saving boot dependencies 2:20:23 PM: Started saving rust rustup cache 2:20:23 PM: Finished saving rust rustup cache 2:20:24 PM: Started saving go dependencies 2:20:25 PM: Finished saving go dependencies 2:20:28 PM: Build failed due to a user error: Build script returned non-zero exit code: 2 2:20:28 PM: Creating deploy upload records 2:20:28 PM: Failing build: Failed to build site 2:20:28 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2) 2:20:28 PM: Finished processing build request in 36.348796435s

I hope that is enough info, any help would be greatly appreciated.

Thank you so much! :slight_smile:

Hi all! after a goods nights sleep I noticed an error in my nunjucks code:

`{% include “/components/reviewlist.njk” %}

should have been {% include "../components/reviewList.njk" %} (note “…” and the case sensitive name"

I have no idea how the build was running locally even after deleting my _site dir and restarting the whole build from scratch.

Hope it helps someone in future :slight_smile: