skip to Main Content

Gatsby build on netlify used to work perfectly, but suddenly stopped working. It builds locally, but returns error bash: gatsby: command not found on netlify.

What I’ve already tried:

  • change the build command to "npm run build";
  • set the node/yarn/npm versions as environment variables;
  • deploy with package-lock AND yarn-lock (not at the same time);

Link to the repository: https://github.com/ramosht/ramosht.com

Log:

10:08:50 AM: Build ready to start
10:08:52 AM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
10:08:52 AM: build-image tag: v3.4.1
10:08:52 AM: buildbot version: 9042ba4998dab698f1f37fb8d36912c08a387191
10:08:52 AM: Building without cache
10:08:52 AM: Starting to prepare the repo for build
10:08:52 AM: No cached dependencies found. Cloning fresh repo
10:08:52 AM: git clone https://github.com/ramosht/ramosht
10:08:52 AM: Preparing Git Reference refs/heads/master
10:08:54 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
10:08:54 AM: Starting build script
10:08:54 AM: Installing dependencies
10:08:54 AM: Python version set to 2.7
10:08:55 AM: Downloading and installing node v10.22.0...
10:08:55 AM: Downloading https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-x64.tar.xz...
10:08:55 AM: Computing checksum with sha256sum
10:08:55 AM: Checksums matched!
10:08:58 AM: Now using node v10.22.0 (npm v6.14.6)
10:08:58 AM: Started restoring cached build plugins
10:08:58 AM: Finished restoring cached build plugins
10:08:58 AM: Attempting ruby version 2.6.2, read from environment
10:08:59 AM: Using ruby version 2.6.2
10:09:00 AM: Using PHP version 5.6
10:09:00 AM: 5.2 is already installed.
10:09:00 AM: Using Swift version 5.2
10:09:00 AM: Started restoring cached go cache
10:09:00 AM: Finished restoring cached go cache
10:09:00 AM: Installing Go version 1.12
10:09:05 AM: unset GOOS;
10:09:05 AM: unset GOARCH;
10:09:05 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64';
10:09:05 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64/bin:${PATH}";
10:09:05 AM: go version >&2;
10:09:05 AM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.12.linux.amd64.env"
10:09:05 AM: go version go1.12 linux/amd64
10:09:05 AM: Installing missing commands
10:09:05 AM: Verify run directory
10:09:06 AM: ​
10:09:06 AM: ┌─────────────────────────────┐
10:09:06 AM: │        Netlify Build        │
10:09:06 AM: └─────────────────────────────┘
10:09:06 AM: ​
10:09:06 AM: ❯ Version
10:09:06 AM:   @netlify/build 3.1.10
10:09:06 AM: ​
10:09:06 AM: ❯ Flags
10:09:06 AM:   deployId: 5f392fe2ad43c45468a78a0b
10:09:06 AM:   mode: buildbot
10:09:06 AM:   timersFile: /tmp/substage_times.txt
10:09:06 AM: ​
10:09:06 AM: ❯ Current directory
10:09:06 AM:   /opt/build/repo
10:09:06 AM: ​
10:09:06 AM: ❯ Config file
10:09:06 AM:   No config file was defined: using default values.
10:09:06 AM: ​
10:09:06 AM: ❯ Context
10:09:06 AM:   production
10:09:06 AM: ​
10:09:06 AM: ┌───────────────────────────────────┐
10:09:06 AM: │ 1. Build command from Netlify app │
10:09:06 AM: └───────────────────────────────────┘
10:09:06 AM: ​
10:09:06 AM: $ gatsby builud
10:09:06 AM: bash: gatsby: command not found
10:09:06 AM: ​
10:09:06 AM: ┌─────────────────────────────┐
10:09:06 AM: │   "build.command" failed    │
10:09:06 AM: └─────────────────────────────┘
10:09:06 AM: ​
10:09:06 AM:   Error message
10:09:06 AM:   Command failed with exit code 127: gatsby builud
10:09:06 AM: ​
10:09:06 AM:   Error location
10:09:06 AM:   In Build command from Netlify app:
10:09:06 AM:   gatsby builud
10:09:06 AM: ​
10:09:06 AM:   Resolved config
10:09:06 AM:   build:
10:09:06 AM:     command: gatsby builud
10:09:06 AM:     commandOrigin: ui
10:09:06 AM:     environment:
10:09:06 AM:       - GOOGLE_ANALYTICS_TRACKING_ID
10:09:06 AM:     publish: /opt/build/repo/public
10:09:06 AM: Caching artifacts
10:09:06 AM: Started saving build plugins
10:09:06 AM: Finished saving build plugins
10:09:06 AM: Started saving pip cache
10:09:06 AM: Finished saving pip cache
10:09:06 AM: Started saving emacs cask dependencies
10:09:06 AM: Finished saving emacs cask dependencies
10:09:06 AM: Started saving maven dependencies
10:09:06 AM: Finished saving maven dependencies
10:09:06 AM: Started saving boot dependencies
10:09:06 AM: Finished saving boot dependencies
10:09:07 AM: Started saving go dependencies
10:09:08 AM: Finished saving go dependencies
10:09:11 AM: Error running command: Build script returned non-zero exit code: 1
10:09:11 AM: Failing build: Failed to build site
10:09:11 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
10:09:11 AM: Finished processing build request in 19.80318381s

package.json

{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "",
  "version": "0.1.0",
  "author": "Guilherme Rmos <[email protected]>",
  "dependencies": {
    "@weknow/gatsby-remark-codepen": "^0.1.0",
    "babel-preset-gatsby": "^0.5.1",
    "date-fns": "^2.14.0",
    "gatsby": "^2.19.43",
    "gatsby-cli": "^2.12.60",
    "gatsby-image": "^2.2.43",
    "gatsby-plugin-canonical-urls": "^2.3.0",
    "gatsby-plugin-google-analytics": "^2.3.0",
    "gatsby-plugin-manifest": "^2.2.47",
    "gatsby-plugin-netlify-cms": "^4.3.0",
    "gatsby-plugin-offline": "3.0.40",
    "gatsby-plugin-react-helmet": "^3.1.23",
    "gatsby-plugin-sharp": "^2.4.12",
    "gatsby-plugin-sitemap": "^2.4.1",
    "gatsby-plugin-styled-components": "^3.1.21",
    "gatsby-remark-images": "^3.3.0",
    "gatsby-remark-lazy-load": "^1.0.2",
    "gatsby-remark-prismjs": "3.3.5",
    "gatsby-remark-relative-images": "^0.3.0",
    "gatsby-remark-relative-images-v2": "^0.1.5",
    "gatsby-source-filesystem": "^2.1.55",
    "gatsby-transformer-json": "^2.4.10",
    "gatsby-transformer-remark": "^2.8.23",
    "gatsby-transformer-sharp": "^2.3.18",
    "lazysizes": "^5.2.0",
    "netlify-cms-app": "^2.12.11",
    "prismjs": "1.17.1",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-animated-burgers": "^1.2.7",
    "react-disqus-comments": "^1.4.0",
    "react-dom": "^16.12.0",
    "react-helmet": "^5.2.1",
    "react-responsive": "^8.1.0",
    "save": "^2.4.0",
    "styled-components": "^4.3.2",
    "styled-icons": "^10.2.1",
    "uuidv4": "^6.1.1"
  },
  "devDependencies": {
    "prettier": "^1.19.1"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write "**/*.{js,jsx,json,md}"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo "Write tests! -> https://gatsby.dev/unit-testing" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

3

Answers


  1. I’ve come across it many times in the npm build process and my solution:

    1. Run: set NODE_OPTIONS=–max_old_space_size=4096
    2. Delete node_modules
    3. Run: npm install
    4. Run: yarn install (if you are using)
    5. Run: npm run build

    My method is not sure to work on you but try it.

    I hope it will..

    Login or Signup to reply.
  2. Command failed with exit code 127: gatsby builud

    Also:

    10:09:06 AM:   Error location
    10:09:06 AM:   In Build command from Netlify app:
    10:09:06 AM:   gatsby builud
    

    Spot the typo, builud instead of build. You must have something broke in your deploy commands in Netlify’s dashboard.

    Login or Signup to reply.
  3. If you want to run any yarn command in your build process on netlify then included yarn.lock in your root directory. Even an empty file of yarn.lock will work fine.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search