Home
Support Forums

Gatsby + Prismic website builds successfully in the local machine but not in Netlify

A website built with Gatsby and Prismic gets build successfully in the local machine but not in Netlify. The details are as follows:

Netlify app link: https://ddeepak95.netlify.app/
Github Repo: https://github.com/ddeepak95/deeportfolio
Environment Variables:

NODE_VERSION 14.17.4
NPM_VERSION 6.14.14

Error:

12:05:14 AM: failed Building production JavaScript and CSS bundles - 0.783s
12:05:14 AM: error Generating JavaScript bundles failed
12:05:14 AM: Unknown option: .reactRuntime. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

Complete Log:

12:00:26 AM: Build ready to start
12:00:28 AM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
12:00:28 AM: build-image tag: v4.3.0
12:00:28 AM: buildbot version: b2c4edac4eab845e0e7ebe41f316f2179d56966b
12:00:28 AM: Fetching cached dependencies
12:00:28 AM: Failed to fetch cache, continuing with build
12:00:28 AM: Starting to prepare the repo for build
12:00:28 AM: No cached dependencies found. Cloning fresh repo
12:00:28 AM: git clone https://github.com/ddeepak95/deeportfolio
12:00:29 AM: Preparing Git Reference refs/heads/main
12:00:29 AM: Parsing package.json dependencies
12:00:30 AM: Starting build script
12:00:30 AM: Installing dependencies
12:00:30 AM: Python version set to 2.7
12:00:31 AM: Downloading and installing node v14.17.4...
12:00:31 AM: Downloading https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz...
12:00:31 AM: Computing checksum with sha256sum
12:00:31 AM: Checksums matched!
12:00:34 AM: Now using node v14.17.4 (npm v6.14.14)
12:00:34 AM: Started restoring cached build plugins
12:00:34 AM: Finished restoring cached build plugins
12:00:34 AM: Attempting ruby version 2.7.2, read from environment
12:00:36 AM: Using ruby version 2.7.2
12:00:36 AM: Using PHP version 8.0
12:00:36 AM: Started restoring cached node modules
12:00:36 AM: Finished restoring cached node modules
12:00:36 AM: Installing NPM modules using NPM version 6.14.14
12:00:41 AM: npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
12:00:42 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
12:00:42 AM: npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
12:00:43 AM: npm WARN deprecated fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
12:00:44 AM: npm WARN deprecated graphql-import@0.7.1: GraphQL Import has been deprecated and merged into GraphQL Tools, so it will no longer get updates. Use GraphQL Tools instead to stay up-to-date! Check out https://www.graphql-tools.com/docs/migration-from-import for migration and https://the-guild.dev/blog/graphql-tools-v6 for new changes.
12:00:46 AM: npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
12:01:33 AM: > sharp@0.27.2 install /opt/build/repo/node_modules/sharp
12:01:33 AM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
12:01:34 AM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-linux-x64.tar.br
12:01:36 AM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
12:01:36 AM: > node scripts/install.js
12:01:37 AM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-83_binding.node
12:01:37 AM: Download complete
12:01:37 AM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-83/binding.node
12:01:37 AM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-83_binding.node
12:01:37 AM: > @fortawesome/fontawesome-common-types@0.2.36 postinstall /opt/build/repo/node_modules/@fortawesome/fontawesome-common-types
12:01:37 AM: > node attribution.js
12:01:37 AM: Font Awesome Free 0.2.36 by @fontawesome - https://fontawesome.com
12:01:37 AM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
12:01:37 AM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
12:01:37 AM: > node -e "try{require('./postinstall')}catch(e){}"
12:01:38 AM: > core-js@3.16.3 postinstall /opt/build/repo/node_modules/core-js
12:01:38 AM: > node -e "try{require('./postinstall')}catch(e){}"
12:01:38 AM: > core-js-pure@3.16.3 postinstall /opt/build/repo/node_modules/core-js-pure
12:01:38 AM: > node -e "try{require('./postinstall')}catch(e){}"
12:01:39 AM: > gatsby-telemetry@1.10.2 postinstall /opt/build/repo/node_modules/gatsby-telemetry
12:01:39 AM: > node src/postinstall.js || true
12:01:39 AM: > mozjpeg@7.1.0 postinstall /opt/build/repo/node_modules/mozjpeg
12:01:39 AM: > node lib/install.js
12:01:39 AM:   βœ” mozjpeg pre-build test passed successfully
12:01:39 AM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
12:01:39 AM: > node lib/install.js
12:01:40 AM:   βœ” pngquant pre-build test passed successfully
12:01:40 AM: > gatsby-cli@2.19.3 postinstall /opt/build/repo/node_modules/@prismicio/gatsby-source-prismic-graphql/node_modules/gatsby/node_modules/gatsby-cli
12:01:40 AM: > node scripts/postinstall.js
12:01:40 AM: > gatsby@2.24.11 postinstall /opt/build/repo/node_modules/@prismicio/gatsby-source-prismic-graphql/node_modules/gatsby
12:01:40 AM: > node scripts/postinstall.js
12:01:40 AM: > gatsby-cli@2.19.3 postinstall /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli
12:01:40 AM: > node scripts/postinstall.js
12:01:40 AM: > @fortawesome/fontawesome-svg-core@1.2.36 postinstall /opt/build/repo/node_modules/@fortawesome/fontawesome-svg-core
12:01:40 AM: > node attribution.js
12:01:40 AM: Font Awesome Free 1.2.36 by @fontawesome - https://fontawesome.com
12:01:40 AM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
12:01:40 AM: > @fortawesome/free-brands-svg-icons@5.15.4 postinstall /opt/build/repo/node_modules/@fortawesome/free-brands-svg-icons
12:01:40 AM: > node attribution.js
12:01:40 AM: Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
12:01:40 AM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
12:01:40 AM: > @fortawesome/free-solid-svg-icons@5.15.4 postinstall /opt/build/repo/node_modules/@fortawesome/free-solid-svg-icons
12:01:40 AM: > node attribution.js
12:01:40 AM: Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
12:01:40 AM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
12:01:40 AM: > gatsby@2.32.13 postinstall /opt/build/repo/node_modules/gatsby
12:01:40 AM: > node scripts/postinstall.js
12:01:41 AM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
12:01:41 AM: > node scripts/build.js
12:01:41 AM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-83/binding.node
12:01:41 AM: Testing binary
12:01:41 AM: Binary is fine
12:01:44 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/@prismicio/gatsby-source-prismic-graphql/node_modules/babel-plugin-add-module-exports/node_modules/chokidar/node_modules/fsevents):
12:01:44 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:01:44 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/@prismicio/gatsby-source-prismic-graphql/node_modules/chokidar/node_modules/fsevents):
12:01:44 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:01:44 AM: npm WARN @pmmmwh/react-refresh-webpack-plugin@0.3.3 requires a peer of react-refresh@^0.8.2 but none is installed. You must install peer dependencies yourself.
12:01:44 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
12:01:44 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:01:44 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
12:01:44 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:01:44 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
12:01:44 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:01:44 AM: added 2841 packages from 1429 contributors and audited 2847 packages in 67.358s
12:01:47 AM: 210 packages are looking for funding
12:01:47 AM:   run `npm fund` for details
12:01:47 AM: found 30 vulnerabilities (2 low, 17 moderate, 10 high, 1 critical)
12:01:47 AM:   run `npm audit fix` to fix them, or `npm audit` for details
12:01:47 AM: NPM modules installed
12:01:47 AM: Started restoring cached go cache
12:01:47 AM: Finished restoring cached go cache
12:01:47 AM: go version go1.16.5 linux/amd64
12:01:47 AM: go version go1.16.5 linux/amd64
12:01:47 AM: Installing missing commands
12:01:47 AM: Verify run directory
12:01:48 AM: ​
12:01:48 AM: ────────────────────────────────────────────────────────────────
12:01:48 AM:   Netlify Build                                                 
12:01:48 AM: ────────────────────────────────────────────────────────────────
12:01:48 AM: ​
12:01:48 AM: ❯ Version
12:01:48 AM:   @netlify/build 18.6.0
12:01:48 AM: ​
12:01:48 AM: ❯ Flags
12:01:48 AM:   baseRelDir: true
12:01:48 AM:   buildId: 6127ddc226e259000799a141
12:01:48 AM:   deployId: 6127ddc226e259000799a143
12:01:48 AM: ​
12:01:48 AM: ❯ Current directory
12:01:48 AM:   /opt/build/repo
12:01:48 AM: ​
12:01:48 AM: ❯ Config file
12:01:48 AM:   No config file was defined: using default values.
12:01:48 AM: ​
12:01:48 AM: ❯ Context
12:01:48 AM:   production
12:01:49 AM: ​
12:01:49 AM: ❯ Installing plugins
12:01:49 AM:    - @netlify/plugin-gatsby@1.0.3
12:01:57 AM: ​
12:01:57 AM: ❯ Loading plugins
12:01:57 AM:    - @netlify/plugin-gatsby@1.0.3 from Netlify app
12:01:57 AM: ​
12:01:57 AM: ────────────────────────────────────────────────────────────────
12:01:57 AM:   1. onPreBuild command from @netlify/plugin-gatsby             
12:01:57 AM: ────────────────────────────────────────────────────────────────
12:01:57 AM: ​
12:01:57 AM: No Gatsby cache found. Building fresh.
12:01:57 AM: Add `gatsby-plugin-netlify` to `gatsby-config.js` if you would like to support Gatsby redirects. πŸŽ‰
12:01:57 AM: ​
12:01:57 AM: (@netlify/plugin-gatsby onPreBuild completed in 163ms)
12:01:57 AM: ​
12:01:57 AM: ────────────────────────────────────────────────────────────────
12:01:57 AM:   2. Build command from Netlify app                             
12:01:57 AM: ────────────────────────────────────────────────────────────────
12:01:57 AM: ​
12:01:57 AM: $ npm run build
12:01:57 AM: > deeportfolio@0.1.0 build /opt/build/repo
12:01:57 AM: > gatsby build
12:02:00 AM: success open and validate gatsby-configs - 0.060s
12:02:01 AM: success load plugins - 0.785s
12:02:01 AM: success onPreInit - 0.127s
12:02:01 AM: success delete html and css files from previous builds - 0.003s
12:02:01 AM: success initialize cache - 0.006s
12:02:01 AM: success copy gatsby files - 0.044s
12:02:01 AM: success onPreBootstrap - 0.016s
12:02:01 AM: success createSchemaCustomization - 0.004s
12:02:02 AM: success Checking for changed pages - 0.000s
12:02:02 AM: success source and transform nodes - 0.913s
12:02:03 AM: success building schema - 0.335s
12:02:03 AM: info Total nodes: 59, SitePage nodes: 9 (use --verbose for breakdown)
12:02:03 AM: success createPages - 0.320s
12:02:03 AM: success Checking for changed pages - 0.000s
12:02:03 AM: success createPagesStatefully - 0.104s
12:02:03 AM: success update schema - 0.030s
12:02:03 AM: success onPreExtractQueries - 0.001s
12:02:04 AM: success extract queries from components - 0.847s
12:02:04 AM: warning The GraphQL query in the non-page component "/opt/build/repo/src/templates/post.jsx" will not be run.
12:02:04 AM: Exported queries are only executed for Page components. It's possible you're
12:02:04 AM: trying to create pages in your gatsby-node.js and that's failing for somereason.
12:02:04 AM: If the failing component(s) is a regular component and not intended to be a page
12:02:04 AM: component, you generally want to use a <StaticQuery> (https://gatsbyjs.org/docs/static-query)
12:02:04 AM: instead of exporting a page query.
12:02:04 AM: If you're more experienced with GraphQL, you can also export GraphQLfragments from components and compose the fragments in the Page component
12:02:04 AM: query and pass data down into the child component β€” https://graphql.org/learn/queries/#fragments
12:02:04 AM: success write out redirect data - 0.001s
12:02:04 AM: success Build manifest and related icons - 0.241s
12:02:04 AM: success onPostBootstrap - 0.243s
12:02:04 AM: info bootstrap finished - 6.601s
12:02:04 AM: success run static queries - 0.020s - 1/1 49.61/s
12:02:05 AM: success run page queries - 0.709s - 14/14 19.74/s
12:02:05 AM: success write out requires - 0.004s
12:02:06 AM: failed Building production JavaScript and CSS bundles - 0.836s
12:02:06 AM: error Generating JavaScript bundles failed
12:02:06 AM: Unknown option: .reactRuntime. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
12:02:06 AM: error Generating JavaScript bundles failed
12:02:06 AM: Unknown option: .reactRuntime. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
12:02:06 AM: npm ERR! code ELIFECYCLE
12:02:06 AM: npm ERR! errno 1
12:02:06 AM: npm ERR! deeportfolio@0.1.0 build: `gatsby build`
12:02:06 AM: npm ERR! Exit status 1
12:02:06 AM: npm ERR!
12:02:06 AM: npm ERR! Failed at the deeportfolio@0.1.0 build script.
12:02:06 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:02:06 AM: npm ERR! A complete log of this run can be found in:
12:02:06 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-08-26T18_32_06_233Z-debug.log
12:02:06 AM: ​
12:02:06 AM: ────────────────────────────────────────────────────────────────
12:02:06 AM:   "build.command" failed                                        
12:02:06 AM: ────────────────────────────────────────────────────────────────
12:02:06 AM: ​
12:02:06 AM:   Error message
12:02:06 AM:   Command failed with exit code 1: npm run build
12:02:06 AM: ​
12:02:06 AM:   Error location
12:02:06 AM:   In Build command from Netlify app:
12:02:06 AM:   npm run build
12:02:06 AM: ​
12:02:06 AM:   Resolved config
12:02:06 AM:   build:
12:02:06 AM:     command: npm run build
12:02:06 AM:     commandOrigin: ui
12:02:06 AM:     environment:
12:02:06 AM:       - NODE_VERSION
12:02:06 AM:       - NPM_VERSION
12:02:06 AM:     publish: /opt/build/repo/dist
12:02:06 AM:     publishOrigin: ui
12:02:06 AM:   plugins:
12:02:06 AM:     - inputs: {}
12:02:06 AM:       origin: ui
12:02:06 AM:       package: '@netlify/plugin-gatsby'
12:02:06 AM: Caching artifacts
12:02:06 AM: Started saving node modules
12:02:06 AM: Finished saving node modules
12:02:06 AM: Started saving build plugins
12:02:06 AM: Finished saving build plugins
12:02:06 AM: Started saving pip cache
12:02:06 AM: Finished saving pip cache
12:02:06 AM: Started saving emacs cask dependencies
12:02:06 AM: Finished saving emacs cask dependencies
12:02:06 AM: Started saving maven dependencies
12:02:06 AM: Finished saving maven dependencies
12:02:06 AM: Started saving boot dependencies
12:02:06 AM: Finished saving boot dependencies
12:02:06 AM: Started saving rust rustup cache
12:02:06 AM: Finished saving rust rustup cache
12:02:06 AM: Started saving go dependencies
12:02:06 AM: Finished saving go dependencies
12:02:09 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:02:09 AM: Creating deploy upload records
12:02:09 AM: Failing build: Failed to build site
12:02:09 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:02:09 AM: Finished processing build request in 1m41.303302345s

Please help me with it. Thank you!

It seems to be a known issue, try downgrading gatsby to 2.24.51:

1 Like

Hi @tomrutgers,
Thank you for your response.
Your suggestion fixed the issue but now I’m facing a new one. I’m receiving the following error:

8:40:51 AM: failed Building production JavaScript and CSS bundles - 52.656s
8:40:51 AM: error Generating JavaScript bundles failed
8:40:51 AM: Can't resolve '../../public/static/d/2924840780.json' in '/opt/build/repo/src/components'
8:40:51 AM: If you're trying to use a package make sure that '../../public/static/d/2924840780.json' is installed. If you're trying to use a local file make sure that the path is correct.

I tried deploying after clearing cache too but nothing seems to be working. Please help. Thank you!

Check out this topic:

I tried following the instructions mentioned, @tomrutgers. Still I’m facing the same issue. I’m new to the web development game too. It would be great if you can please check my code when you get the time. Thank you very much!

Hi @ddeepak95,

I think you’d have better luck by asking this on Gatsby forums or GitHub. I tried your repo locally and I still cannot build it. There’s something definitely going wrong in the process and we cannot troubleshoot it.