Path error on netlify but not on dev

I need advice to debug deploy Netlify App. I can deploy this locally but not on netlify. I have tried every path combo imaginable.

Keeps crashing on this

const cfg = require(“…/_data/site.json”);

module.exports = function (path, encode = false) {
if (encode) {
path = encodeURIComponent(path);
}

return `${cfg.url}${path}`;

};

this site.json file is at /src/_data/site.json

1:08:53 AM: Build ready to start

1:09:04 AM: build-image version: 6b66e79d54a8f76b01392124644c3052ac0d32ef
1:09:04 AM: build-image tag: v3.3.6
1:09:04 AM: buildbot version: 2ba6f2db8150441c8469e6ae3ab3561a2c9d03fa
1:09:05 AM: Fetching cached dependencies
1:09:05 AM: Starting to download cache of 142.4MB
1:09:06 AM: Finished downloading cache in 899.10817ms
1:09:06 AM: Starting to extract cache
1:09:10 AM: Finished extracting cache in 4.445878539s
1:09:10 AM: Finished fetching cache in 5.398023425s
1:09:10 AM: Starting to prepare the repo for build
1:09:11 AM: Preparing Git Reference refs/heads/master
1:09:12 AM: Starting build script
1:09:12 AM: Installing dependencies
1:09:12 AM: Started restoring cached node version
1:09:15 AM: Finished restoring cached node version
1:09:15 AM: v10.19.0 is already installed.
1:09:16 AM: Now using node v10.19.0 (npm v6.13.4)
1:09:16 AM: Attempting ruby version 2.6.2, read from environment
1:09:18 AM: Using ruby version 2.6.2
1:09:18 AM: Using PHP version 5.6
1:09:18 AM: Started restoring cached node modules
1:09:18 AM: Finished restoring cached node modules
1:09:18 AM: Started restoring cached yarn cache
1:09:18 AM: Finished restoring cached yarn cache
1:09:19 AM: Installing NPM modules using Yarn version 1.17.0
1:09:19 AM: yarn install v1.17.0
1:09:19 AM: [1/4] Resolving packages…
1:09:20 AM: [2/4] Fetching packages…
1:09:35 AM: info fsevents@2.1.2: The platform “linux” is incompatible with this module.
1:09:35 AM: info “fsevents@2.1.2” is an optional dependency and failed compatibility check. Excluding it from installation.
1:09:35 AM: info fsevents@1.2.11: The platform “linux” is incompatible with this module.
1:09:35 AM: info “fsevents@1.2.11” is an optional dependency and failed compatibility check. Excluding it from installation.
1:09:35 AM: [3/4] Linking dependencies…
1:09:43 AM: [4/4] Building fresh packages…
1:09:46 AM: Done in 26.76s.
1:09:46 AM: NPM modules installed using Yarn
1:09:46 AM: Started restoring cached go cache
1:09:46 AM: Finished restoring cached go cache
1:09:46 AM: unset GOOS;
1:09:46 AM: unset GOARCH;
1:09:46 AM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
1:09:46 AM: export PATH=“/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}”;
1:09:46 AM: go version >&2;
1:09:46 AM: export GIMME_ENV=‘/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
1:09:46 AM: go version go1.12 linux/amd64
1:09:46 AM: Installing missing commands
1:09:46 AM: Verify run directory
1:09:46 AM: Executing user command: ./node_modules/datocms-client/bin/dato.js dump && cross-env NODE_ENV=production run-s clean scripts:prod eleventy:default styles:prod --print-label
1:09:47 AM: Site token is not specified! Please paste your DatoCMS site read-only API token.
1:09:47 AM: >
1:09:48 AM: [clean ]
1:09:48 AM: [clean ] > tai11s@1.0.0 clean /opt/build/repo
1:09:48 AM: [clean ] > rm -rf dist
1:09:48 AM: [clean ]
1:09:48 AM: [scripts:prod ]
1:09:48 AM: [scripts:prod ] > tai11s@1.0.0 scripts:prod /opt/build/repo
1:09:48 AM: [scripts:prod ] > webpack --mode=production
1:09:48 AM: [scripts:prod ]
1:09:50 AM: [scripts:prod ] Hash: 2df1192bc16454142d88
1:09:50 AM: [scripts:prod ] Version: webpack 4.42.0
1:09:50 AM: [scripts:prod ] Time: 927ms
1:09:50 AM: [scripts:prod ] Built at: 03/10/2020 8:09:50 AM
1:09:50 AM: [scripts:prod ] Asset Size Chunks Chunk Names
1:09:50 AM: [scripts:prod ] index.js 1.33 KiB 0 [emitted] main
1:09:50 AM: [scripts:prod ] Entrypoint main = index.js
1:09:50 AM: [scripts:prod ] [0] ./src/scripts/modules/list.js 62 bytes {0} [built]
1:09:50 AM: [scripts:prod ] [1] ./src/scripts/index.js 702 bytes {0} [built]
1:09:50 AM: [eleventy:default]
1:09:50 AM: [eleventy:default] > tai11s@1.0.0 eleventy:default /opt/build/repo
1:09:50 AM: [eleventy:default] > eleventy
1:09:50 AM: [eleventy:default]
1:09:51 AM: [eleventy:default] Eleventy fatal error: (more in DEBUG output)
1:09:51 AM: [eleventy:default] > Error in your Eleventy config file ‘/opt/build/repo/.eleventy.js’. You may need to run npm install.
1:09:51 AM: [eleventy:default]
1:09:51 AM: [eleventy:default] EleventyConfigError was thrown
1:09:51 AM: [eleventy:default] > Cannot find module ‘…/_data/site.json’
1:09:51 AM: [eleventy:default]
1:09:51 AM: [eleventy:default] Error was thrown:
1:09:51 AM: [eleventy:default] Error: Cannot find module ‘…/_data/site.json’
1:09:51 AM: [eleventy:default] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
1:09:51 AM: [eleventy:default] at Function.resolve (internal/modules/cjs/helpers.js:33:19)
1:09:51 AM: [eleventy:default] at Object. (/opt/build/repo/src/filters/httpUrl.js:1:21)
1:09:51 AM: [eleventy:default] at Module._compile (internal/modules/cjs/loader.js:778:30)
1:09:51 AM: [eleventy:default] at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
1:09:51 AM: [eleventy:default] at Module.load (internal/modules/cjs/loader.js:653:32)
1:09:51 AM: [eleventy:default] at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
1:09:51 AM: [eleventy:default] at Function.Module._load (internal/modules/cjs/loader.js:585:3)
1:09:51 AM: [eleventy:default] at Module.require (internal/modules/cjs/loader.js:692:17)
1:09:51 AM: [eleventy:default] at require (internal/modules/cjs/helpers.js:25:18)
1:09:51 AM: [eleventy:default] npm
1:09:51 AM: ERR! code ELIFECYCLE
1:09:51 AM: failed during stage ‘building site’: Build script returned non-zero exit code: 1
1:09:51 AM: [eleventy:default] npm
1:09:51 AM: ERR! errno 1
1:09:51 AM: [eleventy:default] npm
1:09:51 AM: ERR! tai11s@1.0.0 eleventy:default: eleventy
1:09:51 AM: [eleventy:default] npm ERR! Exit status 1
1:09:51 AM: [eleventy:default] npm ERR!
1:09:51 AM: [eleventy:default] npm ERR! Failed at the tai11s@1.0.0 eleventy:default script.
1:09:51 AM: [eleventy:default] npm ERR!
1:09:51 AM: This is probably not a problem with npm. There is likely additional logging output above.
1:09:51 AM: Shutting down logging, 23 messages pending

Can you please share your repo if it’s public and the build command you’re using in the UI or via netlify.toml? Can you also let us know if you’re working from a tutorial somewhere? This will all help us troubleshoot :muscle:

I figured it out. The directory _data was in .gitignore

gah! thanks for sharing that!