Home
Support Forums

Command failed with exit code 1: gatsby build netlify only

Hi there,

I got a problem when i want to deploy my gatsby website on netlify.

When i work locally, everything is Ok. ( with the development server and with the production build).

I look for hours now to find what’s going wrong but it’s a noGo! it is the second website i made with gatsby and the first one got a very similar setting.
Don’t know what’s going wrong, if someone can give me an hand, i would be grathefull.

the name of my netlify app is : frosty-wescoff-210e63.netlify.app

here is the log :

9:52:02 PM: Build ready to start
9:52:04 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
9:52:04 PM: build-image tag: v4.3.0
9:52:04 PM: buildbot version: b804dff13c52d65303f0ba1445af1695479d4e08
9:52:04 PM: Fetching cached dependencies
9:52:04 PM: Failed to fetch cache, continuing with build
9:52:04 PM: Starting to prepare the repo for build
9:52:04 PM: No cached dependencies found. Cloning fresh repo
9:52:04 PM: git clone https://github.com/gindev77/ArtnGreen
9:52:06 PM: Preparing Git Reference refs/heads/master
9:52:06 PM: Parsing package.json dependencies
9:52:07 PM: Starting build script
9:52:07 PM: Installing dependencies
9:52:07 PM: Python version set to 2.7
9:52:08 PM: v16.6.2 is already installed.
9:52:08 PM: Now using node v16.6.2 (npm v7.20.3)
9:52:08 PM: Started restoring cached build plugins
9:52:08 PM: Finished restoring cached build plugins
9:52:08 PM: Attempting ruby version 2.7.2, read from environment
9:52:10 PM: Using ruby version 2.7.2
9:52:10 PM: Using PHP version 8.0
9:52:10 PM: Started restoring cached node modules
9:52:10 PM: Finished restoring cached node modules
9:52:10 PM: Installing NPM modules using NPM version 7.20.3
9:52:13 PM: npm WARN old lockfile
9:52:13 PM: npm WARN old lockfile The package-lock.json file was created with an old version of npm,
9:52:13 PM: npm WARN old lockfile so supplemental metadata must be fetched from the registry.
9:52:13 PM: npm WARN old lockfile
9:52:13 PM: npm WARN old lockfile This is a one-time fix-up, please be patient...
9:52:13 PM: npm WARN old lockfile
9:52:46 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
9:52:46 PM: npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
9:52:46 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
9:52:47 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
9:52:50 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:52:50 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
9:52:51 PM: npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:53:07 PM: npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
9:53:07 PM: npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
9:53:08 PM: npm WARN deprecated intl-messageformat-parser@3.6.4: We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser
9:53:08 PM: npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
9:53:09 PM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
9:53:11 PM: npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
9:53:21 PM: npm WARN deprecated @formatjs/intl-unified-numberformat@3.3.7: We have renamed the package to @formatjs/intl-numberformat
9:53:27 PM: added 2336 packages, and audited 2337 packages in 1m
9:53:27 PM: 197 packages are looking for funding
9:53:27 PM:   run `npm fund` for details
9:53:28 PM: 27 vulnerabilities (15 moderate, 10 high, 2 critical)
9:53:28 PM: To address all issues, run:
9:53:28 PM:   npm audit fix
9:53:28 PM: Run `npm audit` for details.
9:53:28 PM: NPM modules installed
9:53:28 PM: Started restoring cached go cache
9:53:28 PM: Finished restoring cached go cache
9:53:28 PM: go version go1.16.5 linux/amd64
9:53:28 PM: go version go1.16.5 linux/amd64
9:53:28 PM: Installing missing commands
9:53:28 PM: Verify run directory
9:53:29 PM: ​
9:53:29 PM: ────────────────────────────────────────────────────────────────
9:53:29 PM:   Netlify Build                                                 
9:53:29 PM: ────────────────────────────────────────────────────────────────
9:53:29 PM: ​
9:53:29 PM: ❯ Version
9:53:29 PM:   @netlify/build 18.2.12
9:53:29 PM: ​
9:53:29 PM: ❯ Flags
9:53:29 PM:   baseRelDir: true
9:53:29 PM:   deployId: 611c136294134c00083a1e79
9:53:29 PM: ​
9:53:29 PM: ❯ Current directory
9:53:29 PM:   /opt/build/repo
9:53:29 PM: ​
9:53:29 PM: ❯ Config file
9:53:29 PM:   No config file was defined: using default values.
9:53:29 PM: ​
9:53:29 PM: ❯ Context
9:53:29 PM:   production
9:53:30 PM: ​
9:53:30 PM: ❯ Installing plugins
9:53:30 PM:    - @netlify/plugin-gatsby@1.0.3
9:53:33 PM: ​
9:53:33 PM: ❯ Loading plugins
9:53:33 PM:    - @netlify/plugin-gatsby@1.0.3 from Netlify app
9:53:34 PM: ​
9:53:34 PM: ────────────────────────────────────────────────────────────────
9:53:34 PM:   1. onPreBuild command from @netlify/plugin-gatsby             
9:53:34 PM: ────────────────────────────────────────────────────────────────
9:53:34 PM: ​
9:53:34 PM: No Gatsby cache found. Building fresh.
9:53:34 PM: Add `gatsby-plugin-netlify` to `gatsby-config.js` if you would like to support Gatsby redirects. 🎉
9:53:34 PM: ​
9:53:34 PM: (@netlify/plugin-gatsby onPreBuild completed in 180ms)
9:53:34 PM: ​
9:53:34 PM: ────────────────────────────────────────────────────────────────
9:53:34 PM:   2. Build command from Netlify app                             
9:53:34 PM: ────────────────────────────────────────────────────────────────
9:53:34 PM: ​
9:53:34 PM: $ echo SITE_RECAPTCHA_KEY=$SITE_RECAPTCHA_KEY >> env.production && gatsby build
9:53:37 PM: success open and validate gatsby-configs - 0.401s
9:53:38 PM: warning Plugin gatsby-plugin-react-helmet is not compatible with your gatsby version 3.0.3 - It requires gatsby@^2.0.0
9:53:38 PM: warning Plugin gatsby-plugin-emotion is not compatible with your gatsby version 3.0.3 - It requires gatsby@^2.0.0
9:53:38 PM: warning Plugin gatsby-plugin-postcss is not compatible with your gatsby version 3.0.3 - It requires gatsby@^2.0.0
9:53:38 PM: warning Plugin gatsby-theme-codebushi is not compatible with your gatsby version 3.0.3 - It requires gatsby@^2.18.7
9:53:38 PM: warning Plugin gatsby-plugin-intl is not compatible with your gatsby version 3.0.3 - It requires gatsby@^2.0.0
9:53:38 PM: success load plugins - 0.879s
9:53:38 PM: success onPreInit - 0.074s
9:53:38 PM: success initialize cache - 0.011s
9:53:38 PM: success copy gatsby files - 0.124s
9:53:38 PM: success onPreBootstrap - 0.025s
9:53:39 PM: success createSchemaCustomization - 0.085s
9:53:39 PM: success Checking for changed pages - 0.000s
9:53:39 PM: success source and transform nodes - 0.145s
9:53:39 PM: success building schema - 0.446s
9:53:39 PM: info Total nodes: 89, SitePage nodes: 1 (use --verbose for breakdown)
9:53:39 PM: success createPages - 0.001s
9:53:39 PM: success Checking for changed pages - 0.000s
9:53:39 PM: success createPagesStatefully - 0.127s
9:53:40 PM: success update schema - 0.153s
9:53:40 PM: success onPreExtractQueries - 0.003s
9:53:41 PM: success extract queries from components - 1.827s
9:53:41 PM: success write out redirect data - 0.005s
9:53:41 PM: success onPostBootstrap - 0.001s
9:53:41 PM: info bootstrap finished - 7.592s
9:53:42 PM: success run static queries - 1.059s - 1/1 0.94/s
9:53:42 PM: success run page queries - 0.019s - 16/16 835.55/s
9:53:43 PM: success write out requires - 0.576s
9:53:43 PM: warning [deprecated gatsby-theme-codebushi] node.fs is deprecated. Please set "resolve.fallback.fs = false".
9:53:43 PM: warning [deprecated default-site-plugin] node.fs is deprecated. Please set "resolve.fallback.fs = false".
9:53:56 PM: error (node:1533) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /opt/build/repo/node_modules/css-loader/node_modules/postcss/package.json.
9:53:56 PM: Update this package.json to use a subpath pattern like "./*".
9:53:56 PM: (Use `node --trace-deprecation ...` to show where the warning was created)
9:53:57 PM: warning ⠀
9:53:57 PM: warning warn - Tailwind is not purging unused styles because no template paths have been provided.
9:53:57 PM: warning warn - If you have manually configured PurgeCSS outside of Tailwind or are deliberately not removing unused styles, set `purge: false` in your Tailwind config file to silence this warning.
9:53:57 PM: warning warn - https://tailwindcss.com/docs/controlling-file-size/#removing-unused-css
9:53:59 PM: 
9:53:59 PM: gatsby-plugin-purgecss: Only processing  /opt/build/repo/src/css/tailwind.css
9:54:32 PM: failed Building production JavaScript and CSS bundles - 48.521s
9:54:32 PM: error Generating JavaScript bundles failed
9:54:32 PM: Module build failed (from ./node_modules/css-loader/dist/cjs.js):
9:54:32 PM: Error: Can't resolve '../../static/images/piscine_et_jardin.jpg' in '/opt/build/repo/src/css'    at finishWithoutResolve (/opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:293:18)
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:362:15
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:410:5
9:54:32 PM:     at eval (eval at create (/opt/build/repo/node_modules/enhanced-resolve/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:410:5
9:54:32 PM:     at eval (eval at create (/opt/build/repo/node_modules/enhanced-resolve/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:87:43
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/Resolver.js:410:5
9:54:32 PM:     at eval (eval at create (/opt/build/repo/node_modules/enhanced-resolve/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/forEachBail.js:16:12
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/AliasPlugin.js:103:14
9:54:32 PM:     at next (/opt/build/repo/node_modules/enhanced-resolve/lib/forEachBail.js:14:3)
9:54:32 PM:     at forEachBail (/opt/build/repo/node_modules/enhanced-resolve/lib/forEachBail.js:24:9)
9:54:32 PM:     at /opt/build/repo/node_modules/enhanced-resolve/lib/AliasPlugin.js:37:5
9:54:32 PM:     at _next1 (eval at create (/opt/build/repo/node_modules/enhanced-resolve/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:8:1)
9:54:32 PM:     at eval (eval at create (/opt/build/repo/node_modules/enhanced-resolve/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:31:1)
9:54:32 PM: ​
9:54:32 PM: ────────────────────────────────────────────────────────────────
9:54:32 PM:   "build.command" failed                                        
9:54:32 PM: ────────────────────────────────────────────────────────────────
9:54:32 PM: ​
9:54:32 PM:   Error message
9:54:32 PM:   Command failed with exit code 1: echo SITE_RECAPTCHA_KEY=$SITE_RECAPTCHA_KEY >> env.production && gatsby build
9:54:32 PM: ​
9:54:32 PM:   Error location
9:54:32 PM:   In Build command from Netlify app:
9:54:32 PM:   echo SITE_RECAPTCHA_KEY=$SITE_RECAPTCHA_KEY >> env.production && gatsby build
9:54:32 PM: ​
9:54:32 PM:   Resolved config
9:54:32 PM:   build:
9:54:32 PM:     command: echo SITE_RECAPTCHA_KEY=$SITE_RECAPTCHA_KEY >> env.production && gatsby build
9:54:32 PM:     commandOrigin: ui
9:54:32 PM:     environment:
9:54:32 PM:       - SITE_RECAPTCHA_KEY
9:54:32 PM:       - SITE_RECAPTCHA_SECRET
9:54:32 PM:     publish: /opt/build/repo/public
9:54:32 PM:     publishOrigin: ui
9:54:32 PM:   plugins:
9:54:32 PM:     - inputs: {}
9:54:32 PM:       origin: ui
9:54:32 PM:       package: '@netlify/plugin-gatsby'
9:54:33 PM: Caching artifacts
9:54:33 PM: Started saving node modules
9:54:33 PM: Finished saving node modules
9:54:33 PM: Started saving build plugins
9:54:33 PM: Finished saving build plugins
9:54:33 PM: Started saving pip cache
9:54:33 PM: Finished saving pip cache
9:54:33 PM: Started saving emacs cask dependencies
9:54:33 PM: Finished saving emacs cask dependencies
9:54:33 PM: Started saving maven dependencies
9:54:33 PM: Finished saving maven dependencies
9:54:33 PM: Started saving boot dependencies
9:54:33 PM: Finished saving boot dependencies
9:54:33 PM: Started saving rust rustup cache
9:54:33 PM: Finished saving rust rustup cache
9:54:33 PM: Started saving go dependencies
9:54:33 PM: Finished saving go dependencies
9:54:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:54:35 PM: Creating deploy upload records
9:54:35 PM: Failing build: Failed to build site
9:54:35 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
9:54:35 PM: Finished processing build request in 2m31.327253364s

i already tried to use the classic command build : “gatsby build” but it remain the same.
I need these environments variable for my recaptcha because as you may know, it’s mandatory to me to use the one from google because the netlify recaptcha won’t work with gatsby website.

thank you in advance.
EDIT : i also read the Documentation regarding the build to check some point but it look like Ok.

4 posts were split to a new topic: Fjord Gatsby build error

Hi @gindev

This line looks the likely cause.

Are you sure the image is in location? Is the filename correct?
Remember piscine_et_jardin.jpg and piscine_et_jardin.JPG are different filenames due to case of file extension.

Hey! thank you very much! you were right! thanks to point me out again on this weird message i already seen. the first time i saw it, i changed the name of my file adding it those underscore. but nothing changed. then i changed the size of the capitalization used for my extension file (JPG → jpg) , but i had error when i start my website in local.
Then here is the problem :
I was calling this image using my css file like that :
background-image: url(’…/…/static/images/piscine_et_jardin.jpg’);
and it work when i am launching the website locally.
Finally, i changed this relative path (it was a mistake and it was not necessary to use it in my code) to this path : background-image: url(’/images/piscine_et_jardin.jpg’);
I think the netlify build handle the paths differently and we must take care of using relative paths in our code. Maybe someone could explain us this behaviour better than me.

1 Like