Build working locally but not on Netlify

I’m not sure why my site is able to build locally but will not deploy on Netlify. As far as I can tell, gatsby-plugin-manifest (and other plugins) are failing to find the file ‘/src/images/favicon.png’, but this file exists! I’m pasting the full build logs below. The site name is ‘jacobfromm’, API ID is 81354c8a-9259-4e38-aab8-ad00c01b7d57. The repository can be found at github.com/Jacob-Fromm/portfolio.

Any help would be greatly appreciated!

12:00:02 PM: Waiting for other deploys from your team to complete
12:01:02 PM: Build ready to start
12:01:04 PM: build-image version: 3571f0130496395a23bffe9820bc78b4f73a6234
12:01:04 PM: build-image tag: v3.7.0
12:01:04 PM: buildbot version: 3d5ccbdc3ba752f1ea34e44e85b7e01dd505414c
12:01:04 PM: Building without cache
12:01:04 PM: Starting to prepare the repo for build
12:01:05 PM: No cached dependencies found. Cloning fresh repo
12:01:05 PM: git clone GitHub - Jacob-Fromm/portfolio: This is my personal website and portfolio.
12:01:07 PM: Preparing Git Reference refs/heads/main
12:01:08 PM: Parsing package.json dependencies
12:01:09 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘public’ versus ‘public/’ in the Netlify UI
12:01:09 PM: Starting build script
12:01:09 PM: Installing dependencies
12:01:09 PM: Python version set to 2.7
12:01:11 PM: v12.18.0 is already installed.
12:01:12 PM: Now using node v12.18.0 (npm v6.14.4)
12:01:12 PM: Started restoring cached build plugins
12:01:12 PM: Finished restoring cached build plugins
12:01:12 PM: Attempting ruby version 2.7.1, read from environment
12:01:14 PM: Using ruby version 2.7.1
12:01:14 PM: Using PHP version 5.6
12:01:14 PM: Started restoring cached node modules
12:01:14 PM: Finished restoring cached node modules
12:01:14 PM: Installing NPM modules using NPM version 6.14.4
12:02:14 PM: > sharp@0.27.0 install /opt/build/repo/node_modules/sharp
12:02:14 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
12:02:16 PM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-linux-x64.tar.br
12:02:19 PM: > husky@4.3.7 install /opt/build/repo/node_modules/husky
12:02:19 PM: > node husky install
12:02:19 PM: husky > Setting up git hooks
12:02:19 PM: CI detected, skipping Git hooks installation.
12:02:19 PM: husky > Done
12:02:19 PM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
12:02:19 PM: > node scripts/install.js
12:02:20 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
12:02:20 PM: Download complete
12:02:20 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
12:02:21 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
12:02:21 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
12:02:21 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
12:02:21 PM: > core-js@3.8.2 postinstall /opt/build/repo/node_modules/core-js
12:02:21 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
12:02:21 PM: > core-js-pure@3.8.2 postinstall /opt/build/repo/node_modules/core-js-pure
12:02:21 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
12:02:23 PM: > gatsby-telemetry@1.8.1 postinstall /opt/build/repo/node_modules/gatsby-telemetry
12:02:23 PM: > node src/postinstall.js || true
12:02:23 PM: > mozjpeg@7.0.0 postinstall /opt/build/repo/node_modules/mozjpeg
12:02:23 PM: > node lib/install.js
12:02:24 PM: :heavy_check_mark: mozjpeg pre-build test passed successfully
12:02:24 PM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
12:02:24 PM: > node lib/install.js
12:02:24 PM: :heavy_check_mark: pngquant pre-build test passed successfully
12:02:24 PM: > gatsby-cli@2.17.1 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
12:02:24 PM: > node scripts/postinstall.js
12:02:24 PM: > gatsby@2.30.2 postinstall /opt/build/repo/node_modules/gatsby
12:02:24 PM: > node scripts/postinstall.js
12:02:25 PM: > husky@4.3.7 postinstall /opt/build/repo/node_modules/husky
12:02:25 PM: > opencollective-postinstall || exit 0
12:02:25 PM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
12:02:25 PM: > node scripts/build.js
12:02:25 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
12:02:25 PM: Testing binary
12:02:25 PM: Binary is fine
12:02:29 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
12:02:29 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
12:02:29 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/chokidar/node_modules/fsevents):
12:02:29 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
12:02:29 PM: added 2429 packages from 1348 contributors and audited 2439 packages in 73.616s
12:02:32 PM: 191 packages are looking for funding
12:02:32 PM: run npm fund for details
12:02:32 PM: found 5 vulnerabilities (3 moderate, 2 high)
12:02:32 PM: run npm audit fix to fix them, or npm audit for details
12:02:32 PM: NPM modules installed
12:02:33 PM: Started restoring cached go cache
12:02:33 PM: Finished restoring cached go cache
12:02:33 PM: go version go1.14.4 linux/amd64
12:02:33 PM: go version go1.14.4 linux/amd64
12:02:33 PM: Installing missing commands
12:02:33 PM: Verify run directory
12:02:35 PM: ​
12:02:35 PM: ────────────────────────────────────────────────────────────────
12:02:35 PM: Netlify Build
12:02:35 PM: ────────────────────────────────────────────────────────────────
12:02:35 PM: ​
12:02:35 PM: ❯ Version
12:02:35 PM: @netlify/build 9.11.2
12:02:35 PM: ​
12:02:35 PM: ❯ Flags
12:02:35 PM: apiHost: api.netlify.com
12:02:35 PM: cacheDir: /opt/build/cache
12:02:35 PM: deployId: 6058bf0201355f123a977d09
12:02:35 PM: mode: buildbot
12:02:35 PM: testOpts:
12:02:35 PM: silentLingeringProcesses: ‘’
12:02:35 PM: ​
12:02:35 PM: ❯ Current directory
12:02:35 PM: /opt/build/repo
12:02:35 PM: ​
12:02:35 PM: ❯ Config file
12:02:35 PM: No config file was defined: using default values.
12:02:35 PM: ​
12:02:35 PM: ❯ Context
12:02:35 PM: production
12:02:35 PM: ​
12:02:35 PM: ────────────────────────────────────────────────────────────────
12:02:35 PM: 1. Build command from Netlify app
12:02:35 PM: ────────────────────────────────────────────────────────────────
12:02:35 PM: ​
12:02:35 PM: $ npm run build
12:02:35 PM: > gatsby-starter-hello-world@0.1.0 build /opt/build/repo
12:02:35 PM: > gatsby build
12:02:39 PM: success open and validate gatsby-configs - 0.057s
12:02:41 PM: success load plugins - 1.081s
12:02:41 PM: error “gatsby-plugin-manifest” threw an error while running the onPreInit lifecycle:
12:02:41 PM: ENOENT: no such file or directory, open ‘src/images/favicon.png’
12:02:41 PM: 139 |
12:02:41 PM: 140 | if (pluginOptions.cache_busting_mode !== “none” && pluginOptions.icon) {
12:02:41 PM: > 141 | pluginOptions.cacheDigest = (0, _gatsbyCoreUtils.createContentDigest)(fs.readFileSync(pluginOptions.icon));
12:02:41 PM: | ^
12:02:41 PM: 142 | }
12:02:41 PM: 143 | };
12:02:41 PM: 144 |
12:02:41 PM:
12:02:41 PM:
12:02:41 PM: Error: ENOENT: no such file or directory, open ‘src/images/favicon.png’
12:02:41 PM:
12:02:41 PM: - gatsby-node.js:141 Object.exports.onPreInit
12:02:41 PM: [repo]/[gatsby-plugin-manifest]/gatsby-node.js:141:78
12:02:41 PM:
12:02:41 PM: - api-runner-node.js:469 runAPI
12:02:41 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:469:22
12:02:41 PM:
12:02:41 PM: - api-runner-node.js:620 Promise.catch.decorateEvent.pluginName
12:02:41 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:620:13
12:02:41 PM:
12:02:41 PM: - debuggability.js:384 Promise._execute
12:02:41 PM: [repo]/[bluebird]/js/release/debuggability.js:384:9
12:02:41 PM:
12:02:41 PM: - promise.js:518 Promise._resolveFromExecutor
12:02:41 PM: [repo]/[bluebird]/js/release/promise.js:518:18
12:02:41 PM:
12:02:41 PM: - promise.js:103 new Promise
12:02:41 PM: [repo]/[bluebird]/js/release/promise.js:103:10
12:02:41 PM:
12:02:41 PM: - api-runner-node.js:618
12:02:41 PM: [repo]/[gatsby]/src/utils/api-runner-node.js:618:16
12:02:41 PM:
12:02:41 PM: - util.js:16 tryCatcher
12:02:41 PM: [repo]/[bluebird]/js/release/util.js:16:23
12:02:41 PM:
12:02:41 PM: - reduce.js:166 Object.gotValue
12:02:41 PM: [repo]/[bluebird]/js/release/reduce.js:166:18
12:02:41 PM:
12:02:41 PM: - reduce.js:155 Object.gotAccum
12:02:41 PM: [repo]/[bluebird]/js/release/reduce.js:155:25
12:02:41 PM:
12:02:41 PM: - util.js:16 Object.tryCatcher
12:02:41 PM: [repo]/[bluebird]/js/release/util.js:16:23
12:02:41 PM:
12:02:41 PM: - promise.js:547 Promise._settlePromiseFromHandler
12:02:41 PM: [repo]/[bluebird]/js/release/promise.js:547:31
12:02:41 PM:
12:02:41 PM: - promise.js:604 Promise._settlePromise
12:02:41 PM: [repo]/[bluebird]/js/release/promise.js:604:18
12:02:41 PM:
12:02:41 PM: - promise.js:649 Promise._settlePromise0
12:02:41 PM: [repo]/[bluebird]/js/release/promise.js:649:10
12:02:41 PM:
12:02:41 PM:
12:02:41 PM: not finished onPreInit - 0.228s
12:02:41 PM: npm ERR! code ELIFECYCLE
12:02:41 PM: npm ERR! errno 1
12:02:41 PM: npm ERR! gatsby-starter-hello-world@0.1.0 build: gatsby build
12:02:41 PM: npm ERR! Exit status 1
12:02:41 PM: npm ERR!
12:02:41 PM: npm ERR! Failed at the gatsby-starter-hello-world@0.1.0 build script.
12:02:41 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:02:41 PM: npm ERR! A complete log of this run can be found in:
12:02:41 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-03-22T16_02_41_331Z-debug.log
12:02:41 PM: ​
12:02:41 PM: ────────────────────────────────────────────────────────────────
12:02:41 PM: “build.command” failed
12:02:41 PM: ────────────────────────────────────────────────────────────────
12:02:41 PM: ​
12:02:41 PM: Error message
12:02:41 PM: Command failed with exit code 1: npm run build
12:02:41 PM: ​
12:02:41 PM: Error location
12:02:41 PM: In Build command from Netlify app:
12:02:41 PM: npm run build
12:02:41 PM: ​
12:02:41 PM: Resolved config
12:02:41 PM: build:
12:02:41 PM: command: npm run build
12:02:41 PM: commandOrigin: ui
12:02:41 PM: publish: /opt/build/repo/public
12:02:41 PM: Caching artifacts
12:02:41 PM: Started saving node modules
12:02:41 PM: Finished saving node modules
12:02:41 PM: Started saving build plugins
12:02:41 PM: Finished saving build plugins
12:02:41 PM: Started saving pip cache
12:02:41 PM: Finished saving pip cache
12:02:41 PM: Started saving emacs cask dependencies
12:02:41 PM: Finished saving emacs cask dependencies
12:02:41 PM: Started saving maven dependencies
12:02:41 PM: Finished saving maven dependencies
12:02:41 PM: Started saving boot dependencies
12:02:41 PM: Finished saving boot dependencies
12:02:41 PM: Started saving rust rustup cache
12:02:41 PM: Finished saving rust rustup cache
12:02:41 PM: Started saving go dependencies
12:02:41 PM: Finished saving go dependencies
12:02:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:02:45 PM: Failing build: Failed to build site
12:02:45 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
12:02:45 PM: Finished processing build request in 1m40.667447429s

Your problem is duplication. Your main website is inside the build-1 folder:

While Netlify is trying to build the root directory. Change your base path to build-1 and it should be fixed.

Hi, @jacob-fromm. Plus one to what @hrishikesh already said.

$ git clone http://github.com/Jacob-Fromm/portfolio
Cloning into 'portfolio'...
warning: redirecting to https://github.com/Jacob-Fromm/portfolio/
remote: Enumerating objects: 428, done.
remote: Counting objects: 100% (428/428), done.
remote: Compressing objects: 100% (244/244), done.
remote: Total 428 (delta 177), reused 367 (delta 122), pack-reused 0
Receiving objects: 100% (428/428), 21.15 MiB | 14.26 MiB/s, done.
Resolving deltas: 100% (177/177), done.
$ cd portfolio/

Does the file src/images/favicon.png exist relative to this directory?

$ ls src/images/favicon.png
ls: src/images/favicon.png: No such file or directory

It says: “No such file or directory”. Pretty sure that means the file doesn’t exist there.

What about under the build-1 directory?

$ ls build-1/src/images/favicon.png
build-1/src/images/favicon.png

There it is! So, indeed, the file is missing at the location you specified according to the build logs.

Thank you so much! This was indeed the issue, and the problem’s now solved.

Thanks so much! Netlify is now deploying the site from portfolio/build-1, working perfectly.

1 Like