Deploy from Github Debug about a "Gatsby build" hold up from forestry cms

nargis.netlify.app

the deploy log is here and I would like to get some support on how I can push this asap!

I use forestry.io cms which updates to my github repo, which publishes to netlify.

I have also asked support peeps at forestry.

@sukhigrewal,

the problem is in here somewhere:

2:40:49 PM: $ gatsby build
2:40:49 PM: bash: gatsby: command not found
2:40:49 PM: ​
2:40:49 PM: ┌─────────────────────────────┐
2:40:49 PM: │   "build.command" failed    │
2:40:49 PM: └─────────────────────────────┘
2:40:49 PM: ​
2:40:49 PM:   Error message
2:40:49 PM:   Command failed with exit code 127: gatsby build
2:40:49 PM: ​
2:40:49 PM:   Error location
2:40:49 PM:   In Build command from Netlify app:
2:40:49 PM:   gatsby build
2:40:49 PM: ​
2:40:49 PM:   Resolved config
2:40:49 PM:   build:
2:40:49 PM:     command: gatsby build
2:40:49 PM:     commandOrigin: ui
2:40:49 PM:     publish: /opt/build/repo/public

I am going to guess that there is no command called “gatsby” in your package.json.

If you post it, we can double check.

The build command you enter in the Netlify UI needs to match what is defined in your package.json needs to match the requirements of your project.

This Support Guide contains a ton of useful debugging tips as well :slight_smile:

1 Like

Hi @perry! I was just ctrl-f-ing through my package.json to see what was going on.

It is located here

Thanks in advance!!

hi there, i don’t have permissions to see that file. can you paste the contents here please?

1 Like

I made the above file public however it’s not the original package.json, which is too long to post here. I’m not sure why it’s so long. I visited the repo of the starter and it’s this short (below) and, I replaced my package.json with it. I still get the same code in deploy log shown here

{
“name”: “foresry-starter-blog-gatsby”,
“private”: true,
“description”: “A simple starter blog to get up and developing quickly with Forestry & Gatsby”,
“license”: “MIT”,
“version”: “0.1.0”,
“author”: “kendall strautman”,
“scripts”: {
“build”: “gatsby build”,
“dev”: “gatsby develop -o”,
“develop”: “yarn dev”,
“format”: “prettier --write src/**/*.{js,jsx}”,
“start”: “yarn dev”,
“serve”: “gatsby serve”,
“test”: “echo "Write tests! → Link not found - Rebrandly”",
“forestry-preview”: “gatsby develop -p 8080 -H 0.0.0.0”
},
“dependencies”: {
“gatsby”: “^2.23.12”,
“gatsby-image”: “^2.4.9”,
“gatsby-plugin-react-helmet”: “^3.3.6”,
“gatsby-plugin-sass”: “^2.3.7”,
“gatsby-plugin-sharp”: “^2.6.14”,
“gatsby-remark-images”: “^3.3.14”,
“gatsby-remark-normalize-paths”: “^1.0.0”,
“gatsby-remark-relative-images”: “^0.3.0”,
“gatsby-source-filesystem”: “^2.3.14”,
“gatsby-transformer-remark”: “^2.8.20”,
“gatsby-transformer-sharp”: “^2.5.7”,
“gatsby-transformer-yaml”: “^2.4.6”,
“node-sass”: “^4.14.1”,
“react”: “^16.13.1”,
“react-dom”: “^16.13.1”,
“react-helmet”: “^6.1.0”,
“typescript”: “^3.9.5”,
“webpack”: “^4.43.0”
},
“devDependencies”: {
“prettier”: “^1.18.2”
},
“keywords”: [
“gatsby”,
“forestry”
],
“repository”: {
“type”: “git”,
“url”: “https://github.com/forestryio/brevifolia-gatsby-forestry
}
}

The original file can’t even be seen here or rendered without a client

hi there, please go ahead and change your build command to “npm run build” and see if that works better.

1 Like

It didn’t

How do I make sure I changed the build command? This is how I changed it, just once at under “scripts”

{
“name”: “foresry-starter-blog-gatsby”,
“private”: true,
“description”: “A simple starter blog to get up and developing quickly with Forestry & Gatsby”,
“license”: “MIT”,
“version”: “0.1.0”,
“scripts”: {
“build”: “npm run build”,
“dev”: “gatsby develop -o”,
“develop”: “yarn dev”,
“format”: “prettier --write src/**/*.{js,jsx}”,
“start”: “yarn dev”,
“serve”: “gatsby serve”,
“test”: “echo "Write tests! → Link not found - Rebrandly”",
“forestry-preview”: “gatsby develop -p 8080 -H 0.0.0.0”
},
“dependencies”: {
“gatsby”: “^2.23.12”,
“gatsby-image”: “^2.4.9”,
“gatsby-plugin-react-helmet”: “^3.3.6”,
“gatsby-plugin-sass”: “^2.3.7”,
“gatsby-plugin-sharp”: “^2.6.14”,
“gatsby-remark-images”: “^3.3.14”,
“gatsby-remark-normalize-paths”: “^1.0.0”,
“gatsby-remark-relative-images”: “^0.3.0”,
“gatsby-source-filesystem”: “^2.3.14”,
“gatsby-transformer-remark”: “^2.8.20”,
“gatsby-transformer-sharp”: “^2.5.7”,
“gatsby-transformer-yaml”: “^2.4.6”,
“node-sass”: “^4.14.1”,
“react”: “^16.13.1”,
“react-dom”: “^16.13.1”,
“react-helmet”: “^6.1.0”,
“typescript”: “^3.9.5”,
“webpack”: “^4.43.0”
},
“devDependencies”: {
“prettier”: “^1.18.2”
},
“keywords”: [
“gatsby”,
“forestry”
],
“repository”: {
“type”: “git”,
“url”: “https://github.com/forestryio/brevifolia-gatsby-forestry
}
}

you need to change your build settings in the Netlify UI to match what is defined in your package.json.

please try changing the package.json back to the way it was before, and then change the build setting in the netlify UI to npm run build.

1 Like

Can you take a look at the original package?
https://raw.githubusercontent.com/sukhigrewal/nargis/master/package-lock.json

I don’t know where the build command would be here

@perry,

I used the original package.json and changed the build settings in the Netlify UI, deploy failed, log below

10:51:35 PM: Build ready to start
10:51:37 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
10:51:37 PM: build-image tag: v3.3.20
10:51:37 PM: buildbot version: 78b5536ab4f742c26705d3e953381b9cde6e22ef
10:51:37 PM: Fetching cached dependencies
10:51:37 PM: Starting to download cache of 254.7KB
10:51:37 PM: Finished downloading cache in 82.040445ms
10:51:37 PM: Starting to extract cache
10:51:37 PM: Failed to fetch cache, continuing with build
10:51:37 PM: Starting to prepare the repo for build
10:51:38 PM: No cached dependencies found. Cloning fresh repo
10:51:38 PM: git clone GitHub - sukhigrewal/nargis
10:51:39 PM: Preparing Git Reference refs/heads/master
10:51:41 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘public’ versus ‘public/’ in the Netlify UI
10:51:41 PM: Starting build script
10:51:41 PM: Installing dependencies
10:51:41 PM: Python version set to 2.7
10:51:44 PM: Downloading and installing node v10.21.0…
10:51:44 PM: Downloading https://nodejs.org/dist/v10.21.0/node-v10.21.0-linux-x64.tar.xz
10:51:44 PM: Computing checksum with sha256sum
10:51:44 PM: Checksums matched!
10:51:47 PM: Now using node v10.21.0 (npm v6.14.4)
10:51:47 PM: Started restoring cached build plugins
10:51:47 PM: Finished restoring cached build plugins
10:51:47 PM: Attempting ruby version 2.6.2, read from environment
10:51:49 PM: Using ruby version 2.6.2
10:51:49 PM: Using PHP version 5.6
10:51:49 PM: 5.2 is already installed.
10:51:49 PM: Using Swift version 5.2
10:51:49 PM: Started restoring cached go cache
10:51:49 PM: Finished restoring cached go cache
10:51:49 PM: Installing Go version 1.12
10:51:55 PM: unset GOOS;
10:51:55 PM: unset GOARCH;
10:51:55 PM: export GOROOT=‘/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64’;
10:51:55 PM: export PATH=“/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64/bin:${PATH}”;
10:51:55 PM: go version >&2;
10:51:55 PM: export GIMME_ENV=“/opt/buildhome/.gimme_cache/env/go1.12.linux.amd64.env”
10:51:55 PM: go version go1.12 linux/amd64
10:51:55 PM: Installing missing commands
10:51:55 PM: Verify run directory
10:51:56 PM: ​
10:51:56 PM: ┌─────────────────────────────┐
10:51:56 PM: │ Netlify Build │
10:51:56 PM: └─────────────────────────────┘
10:51:56 PM: ​
10:51:56 PM: ❯ Version
10:51:56 PM: @netlify/build 2.0.27
10:51:56 PM: ​
10:51:56 PM: ❯ Flags
10:51:56 PM: deployId: 5f069447c5d8e091f69bbdfd
10:51:56 PM: mode: buildbot
10:51:56 PM: ​
10:51:56 PM: ❯ Current directory
10:51:56 PM: /opt/build/repo
10:51:56 PM: ​
10:51:56 PM: ❯ Config file
10:51:56 PM: No config file was defined: using default values.
10:51:56 PM: ​
10:51:56 PM: ❯ Context
10:51:56 PM: production
10:51:56 PM: ​
10:51:56 PM: ┌───────────────────────────────────┐
10:51:56 PM: │ 1. Build command from Netlify app │
10:51:56 PM: └───────────────────────────────────┘
10:51:56 PM: ​
10:51:56 PM: $ npm run build
10:51:56 PM: npm ERR! code ENOENT
10:51:56 PM: npm ERR! syscall open
10:51:56 PM: npm ERR! path /opt/build/repo/package.json
10:51:56 PM: npm ERR! errno -2
10:51:56 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
10:51:56 PM: npm ERR! enoent This is related to npm not being able to find a file.
10:51:56 PM: npm ERR! enoent
10:51:56 PM: npm ERR! A complete log of this run can be found in:
10:51:56 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-07-09T03_51_56_947Z-debug.log
10:51:57 PM: ​
10:51:57 PM: ┌─────────────────────────────┐
10:51:57 PM: │ “build.command” failed │
10:51:57 PM: └─────────────────────────────┘
10:51:57 PM: ​
10:51:57 PM: Error message
10:51:57 PM: Command failed with exit code 254: npm run build
10:51:57 PM: ​
10:51:57 PM: Error location
10:51:57 PM: In Build command from Netlify app:
10:51:57 PM: npm run build
10:51:57 PM: ​
10:51:57 PM: Resolved config
10:51:57 PM: build:
10:51:57 PM: command: npm run build
10:51:57 PM: commandOrigin: ui
10:51:57 PM: publish: /opt/build/repo/public
10:51:57 PM: Caching artifacts
10:51:57 PM: Started saving build plugins
10:51:57 PM: Finished saving build plugins
10:51:57 PM: Started saving pip cache
10:51:57 PM: Finished saving pip cache
10:51:57 PM: Started saving emacs cask dependencies
10:51:57 PM: Finished saving emacs cask dependencies
10:51:57 PM: Started saving maven dependencies
10:51:57 PM: Finished saving maven dependencies
10:51:57 PM: Started saving boot dependencies
10:51:57 PM: Finished saving boot dependencies
10:51:57 PM: Started saving go dependencies
10:51:58 PM: Finished saving go dependencies
10:52:06 PM: Error running command: Build script returned non-zero exit code: 1
10:52:06 PM: Failing build: Failed to build site
10:52:06 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
10:52:06 PM: Finished processing build request in 29.011737662s

yes, it is failing because you have no package.json file:

10:51:56 PM: npm ERR! path /opt/build/repo/package.json
10:51:56 PM: npm ERR! errno -2
10:51:56 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
10:51:56 PM: npm ERR! enoent This is related to npm not being able to find a file.

You need

a.) a package.json file to tell the system which packages your project needs and which commands are defined, which is this section:

“scripts”: {
  “build”: “npm run build”,
  “dev”: “gatsby develop -o”,
  “develop”: “yarn dev”,
  “format”: “prettier --write src/**/*.{js,jsx}”,
  “start”: “yarn dev”,
  “serve”: “gatsby serve”,
  “test”: “echo “Write tests! -> https://gatsby.dev/unit-testing””,
  “forestry-preview”: “gatsby develop -p 8080 -H 0.0.0.0”
},

Here, it says that the commands this app knows how to execute are build, dev, develop, format, start, serve,test, and forestry-preview.

The correct one for deployment to netlify is usually build

  1. The correct settings in your netlify UI that match what is defined in your package.json:

(note: this is from a personal project of mine. You need the correct settings for your project

  1. Both the commands in the UI and in the package.json need to be correct for the type of project you are trying to build. The commands for gatsby are different than the ones for Hugo or for create-react-app for example.
1 Like

Yes @perry

I added a package.json.

It still doesn’t run.

Here is the log netlify.com/sites/nargis/deploys/5f072cd08aba4e0007afc571

4:08:26 PM: ┌─────────────────────────────┐
4:08:26 PM: │ “build.command” failed │
4:08:26 PM: └─────────────────────────────┘
4:08:26 PM: ​
4:08:26 PM: Error message
4:08:26 PM: Command failed with exit code 127: build
4:08:26 PM: ​
4:08:26 PM: Error location
4:08:26 PM: In Build command from Netlify app:
4:08:26 PM: build
4:08:26 PM: ​
4:08:26 PM: Resolved config
4:08:26 PM: build:
4:08:26 PM: command: build
4:08:26 PM: commandOrigin: ui
4:08:26 PM: publish: /opt/build/repo/public

This is my most current run, with a package.json, and the build command tried using 1) build, 2) gatsby build, and 3) npm build run.

None of these work, with or without the package.json, and this did successfully deploy in the past with a package-lock.json and no changes from the default in netlify UI as you call it. I would call it “the topmost settings under build & deploy” in a support situation.

can you post the most recent package.json and a screenshot of your current build settings please?

1 Like

buildset

{
“name”: “nargis blog code name nargis”,
“private”: true,
“description”: “A self-care blog maintained to increase knowledge.”,
“license”: “MIT”,
“version”: “0.1.0”,
“scripts”: {
“build”: “gatsby build”,
“dev”: “gatsby develop -o”,
“develop”: “yarn dev”,
“format”: “prettier --write src/**/*.{js,jsx}”,
“start”: “yarn dev”,
“serve”: “gatsby serve”,
“test”: “echo "Write tests! → Link not found - Rebrandly”",
“forestry-preview”: “gatsby develop -p 8080 -H 0.0.0.0”
},
“dependencies”: {
“gatsby”: “^2.23.12”,
“gatsby-image”: “^2.4.9”,
“gatsby-plugin-react-helmet”: “^3.3.6”,
“gatsby-plugin-sass”: “^2.3.7”,
“gatsby-plugin-sharp”: “^2.6.14”,
“gatsby-remark-images”: “^3.3.14”,
“gatsby-remark-normalize-paths”: “^1.0.0”,
“gatsby-remark-relative-images”: “^0.3.0”,
“gatsby-source-filesystem”: “^2.3.14”,
“gatsby-transformer-remark”: “^2.8.20”,
“gatsby-transformer-sharp”: “^2.5.7”,
“gatsby-transformer-yaml”: “^2.4.6”,
“node-sass”: “^4.14.1”,

"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^6.1.0",
"typescript": "^3.9.5",
"webpack": "^4.43.0"

},
“devDependencies”: {
“prettier”: “^1.18.2”
},
“keywords”: [
“sukhi”,
“grewal”
],
“repository”: {
“type”: “git”,
“url”: “canot post a link to this host github repo”
}
}

The only thing I can think of is to add netlify in the dependencies but I don’t know/know how.

It looks like your latest build did succeed. Did you figure things out?

1 Like

Hey @sukhigrewal,

Here are a few thoughts that might help diagnose the issue:

  • To ensure that things are in step both in the Netlify CI and in your local dev environment, you could test to see if npm is doing the right things in installing all your project dependecies. If they are correctly described in your local package.json file then they will all get installed locally if you run npm install. It’s probably worth deleting your node_module folder and running npm install to ensure that all the necessary dependencies get installed from a clean start. That will be easier than trying to test that same thing only in the netlify CI. A mistake I sometimes make is installing some npm packages without putting their details in the package.json file

  • We’ve been talking about package.json while referencing package-lock.json in this thread. That file should never be edited directly, so just in case it has got muddled along the way, you can delete it and have npm generate it for you automatically. It will do that as part of the same process as above, so zap the lock file and let npm regenerate it for you when you run npm install

  • The package.json snippet that you pasted above has a some things that stick out to me. They might just be artefacts of copying and pasting the text around, I’m not sure, but let’s rule them out. — the json seems to have () fancy quotes / curly quote marks used and mixed in with straight quote marks ("). It looks also like the test property has nested quote marks. I’m not sure that this is valid json. I recommend replacing the curly quotes with straight double quotes throughout the package.json file, and also making sure that this is valid json, by looking for things like the nested quotes in the test property and using single quotes inside the double quotes where necessary. Like this:"

 "test" : "echo 'Write tests! -> https://gatsby.dev/unit-testing'", 

This might help to ensure that everything installs and runs locally in the same way it would in Netlify.

Once you’ve got this freshened up and reinstalled the dependencies, you can try running the build the same way that Netlify will by executing the command:

npm run build

If that fails, you know who have some local things to resolve before pushing things to Netlify to build there.

Fingers crossed! :slight_smile:

1 Like

Yeah @Dennis I did, i’m not even joking it was a developer error in the starter I was using :dizzy_face: :expressionless: :neutral_face:

@perry thank you for sticking with me through this

TO BE CLEAR the exact solution was that the github repo url in the package.json was throwin 404 and did not exist. IT WAS A MISPRINT and as soon as I changed it, and deleted the generated files such as yarn.lock and package-lock.json allowing them to replace themselves…everything worked, shipped, and deployed like a charm. I don’t know if this is the right place for this but since I included forestry cms in my title to include it in the diagnostic process…I will say while it wasn’t the cause for this error it is completely unusable as a cms and I dont recommend it. That is all! Bye.

Wait I recognize you from your 11ty One starter!! @philhawksworth This is amazing I’m BLOWN AWAY because I just read your entire blog last week.

Thank you for your notes.