Replicate Netlify deployment build on local for Gatsby

Hi all,

I’ve been dealing with this weird “bug” where on local my Gatsby site works properly but it “breaks” on Netlify deployment.

I was trying to isolate the issue and I was thinking if I can replicate this locally then I can narrow down the issue.

Here’s an example of the broken page: https://5d2cadd34473ea0009306fc1–ajmalafif.netlify.com/journal/

while on local the branch compiled just fine: https://github.com/ajmalafif/ajmalafif.com/tree/refactor

localhost9000

hi there, can you post your logs please? you can find them in your netlify dashboard. Also, can you provide information on anything you have already tried?

Hi Perry!

I’ll answer your questions first before posting the logs. So when I said “break”, it doesn’t reflect what I have locally and my posts listing page is empty. Naturally I Googled common and similar issues and tried few things;

  1. Terser on resolutions in package.json
  2. Downgrade to 2.10.0 which make successful build but still breaks the site

Hence why I’m figuring out if I can replicate Netlify build on local, not sure why it’s not consistent across.

Logs:

1:33:57 AM: Waiting to build. Currently running 1 concurrent builds on your account
1:33:58 AM: Build ready to start
1:34:00 AM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
1:34:00 AM: build-image tag: v3.3.2
1:34:00 AM: buildbot version: ef8d0929ed0baabafd8bbb7d0b021e1fc24180c0
1:34:00 AM: Fetching cached dependencies
1:34:00 AM: Starting to download cache of 224.9MB
1:34:01 AM: Finished downloading cache in 1.095807436s
1:34:01 AM: Starting to extract cache
1:34:11 AM: Finished extracting cache in 10.161718565s
1:34:12 AM: Finished fetching cache in 11.361416139s
1:34:12 AM: Starting to prepare the repo for build
1:34:12 AM: Preparing Git Reference refs/heads/refactor
1:34:15 AM: Starting build script
1:34:15 AM: Installing dependencies
1:34:16 AM: Started restoring cached node version
1:34:18 AM: Finished restoring cached node version
1:34:19 AM: v10.16.0 is already installed.
1:34:20 AM: Now using node v10.16.0 (npm v6.9.0)
1:34:20 AM: Attempting ruby version 2.6.2, read from environment
1:34:22 AM: Using ruby version 2.6.2
1:34:22 AM: Using PHP version 5.6
1:34:22 AM: Started restoring cached node modules
1:34:22 AM: Finished restoring cached node modules
1:34:24 AM: Started restoring cached go cache
1:34:24 AM: Finished restoring cached go cache
1:34:24 AM: unset GOOS;
1:34:24 AM: unset GOARCH;
1:34:24 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
1:34:24 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
1:34:24 AM: go version >&2;
1:34:24 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
1:34:24 AM: go version go1.12 linux/amd64
1:34:24 AM: Installing missing commands
1:34:24 AM: Verify run directory
1:34:24 AM: Executing user command: gatsby build
1:34:27 AM: success open and validate gatsby-configs — 0.080
1:34:30 AM: success load plugins — 2.454
1:34:30 AM: warning The netlify-cms package is deprecated, please install netlify-cms-app instead. You can do this by running "npm install netlify-cms-app"
1:34:30 AM: success onPreInit — 0.029
1:34:30 AM: success delete html and css files from previous builds — 0.022
1:34:30 AM: success initialize cache — 0.027
1:34:30 AM: success copy gatsby files — 0.044
1:34:30 AM: success onPreBootstrap — 0.027
1:34:30 AM: success source and transform nodes — 0.397
1:34:31 AM: success building schema — 0.457
1:34:31 AM: code block or inline code language not specified in markdown. applying generic code block
1:34:31 AM: warning Attempting to create page "/journal/", but page "/journal" already exists. This could lead to non-deterministic routing behavior
1:34:31 AM: success createPages — 0.432
1:34:31 AM: success createPagesStatefully — 0.075
1:34:31 AM: success onPreExtractQueries — 0.022
1:34:31 AM: success update schema — 0.062
1:34:32 AM: success extract queries from components — 0.549
1:34:32 AM: success write out requires — 0.024
1:34:32 AM: success write out redirect data — 0.023
1:34:34 AM: success Build manifest and related icons — 2.260
1:34:34 AM: success onPostBootstrap — 2.299
1:34:34 AM: info bootstrap finished - 10.270 s
1:34:34 AM: success run static queries — 0.046 — 2/2 147.51 queries/second
1:34:54 AM: gatsby-plugin-purgecss: Ignored  /opt/build/repo/node_modules/prismjs/themes/prism-okaidia.css
1:34:55 AM: gatsby-plugin-purgecss: Only processing  /opt/build/repo/src/styles/main.scss
1:34:56 AM: 
1:34:56 AM: From:  /opt/build/repo/src/styles/main.scss
1:34:56 AM:  Removed Selectors:  [ 'aside',
1:34:56 AM:   'figure',
1:34:56 AM:   'figure',
1:34:56 AM:   'hr',
1:34:56 AM:   'pre',
1:34:56 AM:   'abbr[title]',
1:34:56 AM:   'b',
1:34:56 AM:   'code',
1:34:56 AM:   'kbd',
1:34:56 AM:   'samp',
1:34:56 AM:   'mark',
1:34:56 AM:   'sub',
1:34:56 AM:   'sup',
1:34:56 AM:   'sup',
1:34:56 AM:   'audio',
1:34:56 AM:   'video',
1:34:56 AM:   'audio:not([controls])',
1:34:56 AM:   'optgroup',
1:34:56 AM:   'select',
1:34:56 AM:   'fieldset',
1:34:56 AM:   'progress',
1:34:56 AM:   'details',
1:34:56 AM:   'template',
1:34:56 AM:   '.debug *',
1:34:56 AM:   '.debug-white *',
1:34:56 AM:   '.debug-black *',
1:34:56 AM:   '.debug-grid',
1:34:56 AM:   '.debug-grid-16',
1:34:56 AM:   '.debug-grid-8-solid',
1:34:56 AM:   '.debug-grid-16-solid',
1:34:56 AM:   'fieldset',
1:34:56 AM:   'pre',
1:34:56 AM:   'code',
1:34:56 AM:   'ol',
1:34:56 AM:   'dl',
1:34:56 AM:   'dd',
1:34:56 AM:   'table',
1:34:56 AM:   'td',
1:34:56 AM:   'th',
1:34:56 AM:   'tr',
1:34:56 AM:   '.aspect-ratio',
1:34:56 AM:   '.aspect-ratio--16x9',
1:34:56 AM:   '.aspect-ratio--9x16',
1:34:56 AM:   '.aspect-ratio--4x3',
1:34:56 AM:   '.aspect-ratio--3x4',
1:34:56 AM:   '.aspect-ratio--6x4',
1:34:56 AM:   '.aspect-ratio--4x6',
1:34:56 AM:   '.aspect-ratio--8x5',
1:34:56 AM:   '.aspect-ratio--5x8',
1:34:56 AM:   '.aspect-ratio--7x5',
1:34:56 AM:   '.aspect-ratio--5x7',
1:34:56 AM:   '.aspect-ratio--1x1',
1:34:56 AM:   '.aspect-ratio--object',
1:34:56 AM:   '.aspect-ratio-ns',
1:34:56 AM:   '.aspect-ratio--16x9-ns',
1:34:56 AM:   '.aspect-ratio--9x16-ns',
1:34:56 AM:   '.aspect-ratio--4x3-ns',
1:34:56 AM:   '.aspect-ratio--3x4-ns',
1:34:56 AM:   '.aspect-ratio--6x4-ns',
1:34:56 AM:   '.aspect-ratio--4x6-ns',
1:34:56 AM:   '.aspect-ratio--8x5-ns',
1:34:56 AM:   '.aspect-ratio--5x8-ns',
1:34:56 AM:   '.aspect-ratio--7x5-ns',
1:34:56 AM:   '.aspect-ratio--5x7-ns',
1:34:56 AM:   '.aspect-ratio--1x1-ns',
1:34:56 AM:   '.aspect-ratio--object-ns',
1:34:56 AM:   '.aspect-ratio-m',
1:34:56 AM:   '.aspect-ratio--16x9-m',
1:34:56 AM:   '.aspect-ratio--9x16-m',
1:34:56 AM:   '.aspect-ratio--4x3-m',
1:34:56 AM:   '.aspect-ratio--3x4-m',
1:35:05 AM: Starting post processing
1:34:56 AM:   '.aspect-ratio--6x4-m',
1:34:56 AM:   '.aspect-ratio--4x6-m',
1:34:56 AM:   '.aspect-ratio--8x5-m',
1:34:56 AM:   '.aspect-ratio--5x8-m',
1:34:56 AM:   '.aspect-ratio--7x5-m',
1:34:56 AM:   '.aspect-ratio--5x7-m',
1:34:56 AM:   '.aspect-ratio--1x1-m',
1:35:06 AM: Post processing done
1:34:56 AM:   '.aspect-ratio--object-m',
1:34:56 AM:   '.aspect-ratio-l',
1:35:06 AM: Site is live
1:34:56 AM:   '.aspect-ratio--16x9-l',
1:34:56 AM:   '.aspect-ratio--9x16-l',
1:34:56 AM:   '.aspect-ratio--4x3-l',
1:34:56 AM:   '.aspect-ratio--3x4-l',
1:34:56 AM:   '.aspect-ratio--6x4-l',
1:34:56 AM:   '.aspect-ratio--4x6-l',
1:34:56 AM:   '.aspect-ratio--8x5-l',
1:34:56 AM:   '.aspect-ratio--5x8-l',
1:34:56 AM:   '.aspect-ratio--7x5-l',
1:34:56 AM:   '.aspect-ratio--5x7-l',
1:34:56 AM:   '.aspect-ratio--1x1-l',
1:34:56 AM:   '.aspect-ratio--object-l',
1:34:56 AM:   '.cover',
1:34:56 AM:   '.contain',
1:34:56 AM:   '.cover-ns',
1:34:56 AM:   '.contain-ns',
1:34:56 AM:   '.cover-m',
1:34:56 AM:   '.contain-m',
1:34:56 AM:   '.cover-l',
1:34:56 AM:   '.contain-l',
1:34:56 AM:   ... 2000 more items ]
1:34:59 AM: success Building production JavaScript and CSS bundles — 24.669
1:35:00 AM: success Rewriting compilation hashes — 0.077
1:35:02 AM: success run page queries — 2.299 — 34/34 15.42 queries/second
1:35:02 AM: success Generating image thumbnails — 12/12 - 2.463 s
1:35:02 AM: 
1:35:02 AM: gatsby-plugin-purgecss:
1:35:02 AM:  Previous CSS Size: 138.04 KB
1:35:02 AM:  New CSS Size: 36.67 KB (-73.44%)
1:35:02 AM:  Removed ~101.37 KB of CSS
1:35:02 AM: 
1:35:04 AM: success Building static HTML for pages — 1.901 — 34/34 38.38 pages/second
1:35:04 AM: Generated public/sw.js, which will precache 12 files, totaling 518875 bytes.
1:35:04 AM: info Done building in 40.091 sec
1:35:05 AM: Skipping functions preparation step: no functions directory set
1:35:05 AM: Caching artifacts
1:35:05 AM: Started saving node modules
1:35:05 AM: Finished saving node modules
1:35:05 AM: Started saving pip cache
1:35:05 AM: Finished saving pip cache
1:35:05 AM: Started saving emacs cask dependencies
1:35:05 AM: Finished saving emacs cask dependencies
1:35:05 AM: Started saving maven dependencies
1:35:05 AM: Finished saving maven dependencies
1:35:05 AM: Started saving boot dependencies
1:35:05 AM: Finished saving boot dependencies
1:35:05 AM: Started saving go dependencies
1:35:05 AM: Finished saving go dependencies
1:35:05 AM: Build script success
1:35:05 AM: Starting to deploy site from 'public/'
1:35:05 AM: Creating deploy tree 
1:35:05 AM: 0 new files to upload
1:35:05 AM: 0 new functions to upload
1:35:46 AM: Finished processing build request in 1m45.627554766s

Thanks for looking out!

Hi @ajmalafif, can you try reproducing the issue using our build-image on your local machine? This post goes through the steps on how to debug your build with our build-image. Let me know how that goes.