Cloudflare Pages Gatsby Not Found

package.json

{
  "name": "gatsby-starter-shopify",
  "version": "1.0.0",
  "private": true,
  "description": "A Gatsby starter using the latest Shopify plugin showcasing a store with product overview, individual product pages, and a cart.",
  "author": "LekoArts <[email protected]>",
  "license": "0BSD",
  "keywords": [
    "gatsby",
    "shopify",
    "starter",
    "ecommerce",
    "e-commerce"
  ],
  "scripts": {
    "develop": "gatsby develop",
    "start": "gatsby develop",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "clean": "gatsby clean"
  },
  "dependencies": {
    "@emotion/react": "^11.11.1",
    "@emotion/styled": "^11.11.0",
    "@headlessui/react": "^1.7.15",
    "@sindresorhus/slugify": "^1.1.0",
    "@tailwindcss/forms": "^0.5.3",
    "@tailwindcss/typography": "^0.5.9",
    "debounce": "^1.2.1",
    "dotenv": "^10.0.0",
    "embla-carousel-react": "^8.0.0-rc10",
    "gatsby": "^5.0.0",
    "gatsby-plugin-emotion": "^8.11.0",
    "gatsby-plugin-gatsby-cloud": "^5.0.0",
    "gatsby-plugin-google-analytics": "^5.0.0",
    "gatsby-plugin-image": "^3.0.0",
    "gatsby-plugin-sharp": "^5.0.0",
    "gatsby-plugin-sitemap": "^6.0.0",
    "gatsby-source-filesystem": "^5.0.0",
    "gatsby-source-shopify": "^8.11.0",
    "gatsby-transformer-sharp": "^5.0.0",
    "isomorphic-fetch": "^3.0.0",
    "lodash.debounce": "^4.0.8",
    "lodash.isequal": "^4.5.0",
    "query-string": "^7.0.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-icons": "^4.1.0",
    "shopify-buy": "^2.11.0",
    "tailwindcss": "^3.3.2",
    "twin.macro": "^3.3.1",
    "urql": "^2.0.2"
  }
}

log

21:45:56.704	Executing user command: gatsby build
21:45:56.711	/bin/sh: 1: gatsby: not found
21:45:56.712	Failed: Error while executing user command. Exited with error code: 127
21:45:56.722	Failed: build command exited with code: 1
21:45:57.654	Failed: error occurred while running build command

There are some warnings, but I can develop and build locally fine,

Here’s the full log:

2023-07-12T01:45:10.623625Z	Cloning repository...
2023-07-12T01:45:13.241643Z	From https://github.com/jjrchrds/fluff-and-fidget-gatsby
2023-07-12T01:45:13.242395Z	 * branch            d381be9de1e2590bba9d15346afbebeb2fdda38b -> FETCH_HEAD
2023-07-12T01:45:13.242603Z	
2023-07-12T01:45:13.396045Z	HEAD is now at d381be9 fix(update)
2023-07-12T01:45:13.396746Z	
2023-07-12T01:45:13.51687Z	
2023-07-12T01:45:13.5493Z	Success: Finished cloning repository files
2023-07-12T01:45:14.214815Z	Detected the following tools from environment: [email protected], [email protected]
2023-07-12T01:45:14.215584Z	Installing nodejs 18.16.0
2023-07-12T01:45:15.488037Z	Trying to update node-build... ok
2023-07-12T01:45:15.769871Z	Downloading node-v18.16.0-linux-x64.tar.gz...
2023-07-12T01:45:15.770255Z	-> https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-x64.tar.gz
2023-07-12T01:45:18.146883Z	Installing node-v18.16.0-linux-x64...
2023-07-12T01:45:19.668304Z	Installed node-v18.16.0-linux-x64 to /opt/buildhome/.asdf/installs/nodejs/18.16.0
2023-07-12T01:45:19.668889Z	
2023-07-12T01:45:21.05978Z	Installing project dependencies: npm clean-install --progress=false
2023-07-12T01:45:23.328914Z	npm WARN ERESOLVE overriding peer dependency
2023-07-12T01:45:23.329718Z	npm WARN While resolving: [email protected]
2023-07-12T01:45:23.330026Z	npm WARN Found: [email protected]
2023-07-12T01:45:23.330288Z	npm WARN node_modules/react
2023-07-12T01:45:23.330519Z	npm WARN   react@"^18.0.0" from the root project
2023-07-12T01:45:23.330671Z	npm WARN   16 more (@emotion/react, @emotion/styled, ...)
2023-07-12T01:45:23.330816Z	npm WARN 
2023-07-12T01:45:23.330966Z	npm WARN Could not resolve dependency:
2023-07-12T01:45:23.33111Z	npm WARN peer react@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
2023-07-12T01:45:23.331264Z	npm WARN node_modules/react-server-dom-webpack
2023-07-12T01:45:23.331397Z	npm WARN   react-server-dom-webpack@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
2023-07-12T01:45:23.331544Z	npm WARN   node_modules/gatsby
2023-07-12T01:45:23.331688Z	npm WARN 
2023-07-12T01:45:23.331823Z	npm WARN Conflicting peer dependency: [email protected]
2023-07-12T01:45:23.332304Z	npm WARN node_modules/react
2023-07-12T01:45:23.332496Z	npm WARN   peer react@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
2023-07-12T01:45:23.332689Z	npm WARN   node_modules/react-server-dom-webpack
2023-07-12T01:45:23.332898Z	npm WARN     react-server-dom-webpack@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
2023-07-12T01:45:23.333112Z	npm WARN     node_modules/gatsby
2023-07-12T01:45:27.880121Z	npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
2023-07-12T01:45:27.969204Z	npm WARN deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
2023-07-12T01:45:32.180853Z	npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
2023-07-12T01:45:56.671247Z	
2023-07-12T01:45:56.67182Z	added 1404 packages, and audited 1405 packages in 35s
2023-07-12T01:45:56.672063Z	
2023-07-12T01:45:56.672212Z	238 packages are looking for funding
2023-07-12T01:45:56.672344Z	  run `npm fund` for details
2023-07-12T01:45:56.673815Z	
2023-07-12T01:45:56.674068Z	found 0 vulnerabilities
2023-07-12T01:45:56.704138Z	Executing user command: gatsby build
2023-07-12T01:45:56.711163Z	/bin/sh: 1: gatsby: not found
2023-07-12T01:45:56.712396Z	Failed: Error while executing user command. Exited with error code: 127
2023-07-12T01:45:56.722616Z	Failed: build command exited with code: 1
2023-07-12T01:45:57.654272Z	Failed: error occurred while running build command

Do npm run build or install Gatsby globally (npm i -g gatsby)

npm doesn’t put binaries in PATH unless they’re installed globally, so you either need to run through scripts (which executes node_modules/.bin) or install globally so it’s in PATH

2 Likes

Interesting. I set the build command in cloudflare to npm run build and it worked. I get what you’re saying, but why would other projects work w/ gatsby build (default from cloudflare)?

Which build image version with Pages are you using?

Build image v1 added the local node_modules/.bin to PATH so this kinda thing worked, but was a little non-standard.

Build image v2 no longer does this, so the recommended approach is via an npm run script as @WalshyMVP suggested, or npx.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.