Problem with gatsby: command not found when deploying gatsby site to netlify - reactjs

I was trying to deploy gatsby site to Netlify. I commit all files from public directory within gatsby project to my github repository and then deploy that repository on netlify, but I got an error.
After pushing to github all files and directories except for public and then deploy I got following error:
12:23:37 PM: ​
12:23:37 PM: ┌─────────────────────────────┐
12:23:37 PM: │ Netlify Build │
12:23:37 PM: └─────────────────────────────┘
12:23:37 PM: ​
12:23:37 PM: ❯ Version
12:23:37 PM: #netlify/build 3.3.0
12:23:37 PM: ​
12:23:37 PM: ❯ Flags
12:23:37 PM: deployId: 5f4637d3e090c2ab4a26309c
12:23:37 PM: mode: buildbot
12:23:37 PM: ​
12:23:37 PM: ❯ Current directory
12:23:37 PM: /opt/build/repo
12:23:37 PM: ​
12:23:37 PM: ❯ Config file
12:23:37 PM: No config file was defined: using default values.
12:23:37 PM: ​
12:23:37 PM: ❯ Context
12:23:37 PM: production
12:23:37 PM: ​
12:23:37 PM: ┌───────────────────────────────────┐
12:23:37 PM: │ 1. Build command from Netlify app │
12:23:37 PM: └───────────────────────────────────┘
12:23:37 PM: ​
12:23:37 PM: $ gatsby build
12:23:40 PM: success open and validate gatsby-configs - 0.022s
12:23:40 PM: success load plugins - 0.498s
12:23:40 PM: success onPreInit - 0.040s
12:23:40 PM: success delete html and css files from previous builds - 0.002s
12:23:40 PM: success initialize cache - 0.006s
12:23:41 PM: success copy gatsby files - 0.028s
12:23:41 PM: success onPreBootstrap - 0.005s
12:23:41 PM: success createSchemaCustomization - 0.006s
12:23:41 PM: success Checking for changed pages - 0.000s
12:23:41 PM: success source and transform nodes - 0.086s
12:23:41 PM: success building schema - 0.271s
12:23:41 PM: success createPages - 0.001s
12:23:41 PM: success Checking for changed pages - 0.000s
12:23:41 PM: success createPagesStatefully - 0.067s
12:23:41 PM: success update schema - 0.023s
12:23:41 PM: success onPreExtractQueries - 0.001s
12:23:43 PM: success extract queries from components - 2.444s
12:23:43 PM: success write out redirect data - 0.001s
12:23:43 PM: success onPostBootstrap - 0.000s
12:23:43 PM: info bootstrap finished - 6.517s
12:23:44 PM: success run static queries - 0.017s - 1/1 60.34/s
12:23:44 PM: success run page queries - 0.004s - 1/1 241.80/s
12:23:44 PM: success write out requires - 0.004s
12:24:11 PM: success Building production JavaScript and CSS bundles - 27.400s
12:24:11 PM: success Rewriting compilation hashes - 0.002s
12:24:15 PM: failed Building static HTML for pages - 3.641s
12:24:15 PM: error "document" is not available during server side rendering.
12:24:15 PM:
12:24:15 PM: > 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AOS=t():e.AOS=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="dist/",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=n(1),a=(o(r),n(6)),u=o(a),c=n(7),s=o(c),f=n(8),d=o(f),l=n(9),p=o(l),m=n(10),b=o(m),v=n(11),y=o(v),g=n(14),h=o(g),w=[],k=!1,x={offset:120,delay:0,easing:"ease",duration:400,disable:!1,once:!1,startEvent:"DOMContentLoaded",throttleDelay:99,debounceDelay:50,disableMutationObserver:!1},j=function(){var e=arguments.length>0&&void
12:24:15 PM: | ^
12:24:15 PM:
12:24:15 PM: WebpackError: ReferenceError: document is not defined
12:24:15 PM:
12:24:15 PM: - aos.js:1
12:24:15 PM: node_modules/aos/dist/aos.js:1:14565
12:24:15 PM:
12:24:15 PM: - aos.js:1
12:24:15 PM: node_modules/aos/dist/aos.js:1:1506
12:24:15 PM:
12:24:15 PM: - Technologie.js:8
12:24:15 PM: src/components/Technologie.js:8:5
12:24:15 PM:
12:24:15 PM: - index.js:1
12:24:15 PM: src/pages/index.js:1:1
12:24:15 PM:
12:24:15 PM: - getLayoutRect.js:1
12:24:15 PM: node_modules/#popperjs/core/lib/dom-utils/getLayoutRect.js:1:1
12:24:15 PM:
12:24:15 PM:
12:24:15 PM: ​
12:24:15 PM: ┌─────────────────────────────┐
12:24:15 PM: │ "build.command" failed │
12:24:15 PM: └─────────────────────────────┘
12:24:15 PM: ​
12:24:15 PM: Error message
12:24:15 PM: Command failed with exit code 1: gatsby build
12:24:15 PM: ​
12:24:15 PM: Error location
12:24:15 PM: In Build command from Netlify app:
12:24:15 PM: gatsby build
12:24:15 PM: ​
12:24:15 PM: Resolved config
12:24:15 PM: build:
12:24:15 PM: command: gatsby build
12:24:15 PM: commandOrigin: ui
12:24:15 PM: publish: /opt/build/repo/public
12:24:15 PM: Caching artifacts
12:24:15 PM: Started saving node modules
12:24:15 PM: Finished saving node modules
12:24:15 PM: Started saving build plugins
12:24:15 PM: Finished saving build plugins
12:24:15 PM: Started saving pip cache
12:24:15 PM: Finished saving pip cache
12:24:15 PM: Started saving emacs cask dependencies
12:24:15 PM: Finished saving emacs cask dependencies
12:24:15 PM: Started saving maven dependencies
12:24:15 PM: Finished saving maven dependencies
12:24:15 PM: Started saving boot dependencies
12:24:15 PM: Finished saving boot dependencies
12:24:15 PM: Started saving go dependencies
12:24:15 PM: Finished saving go dependencies
12:24:18 PM: Error running command: Build script returned non-zero exit code: 1
12:24:18 PM: Failing build: Failed to build site
12:24:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:24:19 PM: Finished processing build request in 2m5.540557721s
Any suggestions? Thanks in advance.

There's a process misunderstanding there. In your repository, you should commit all files except your /public folder since it's the one that will be generated in the building and deploy process in Netlify. In addition, your netlify.toml is not adding any useful command to Netlify because they are added by default in the dashboard. As you can see in:
Note: you can find this configuration under https://app.netlify.com/sites/YOUR_PROJECT_NAME/settings/deploys
Your command is failing because you are doing the Netlify work in your repository. You are uploading a built folder (/public) that doesn't contain any package.json nor build commands so your command is unrecognized.
You must upload all files except your /public folder in your repository and let Netlify do the build process. In addition, you can improve your netlify.toml by removing the default commands.
With the new edited content it's inferred that
this build must fail locally too before pushing it to Netlify. In Gatsby, you have to check for the availability of the global objects (like window or document before using it).
It's a broad question and spreads the topic of it. If the error is in your code (you are using document object) you need to add a condition first:
If (typeof document !== 'undefined') {
//Your code here
}
If the error comes from an external source (library or dependency using window or document internally), you need to add a null loader in your webpack's configuration:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /bad-module/,
use: loaders.null(),
},
],
},
})
}
}
Replacing /bad-module/ for the library path in node_modules.
You can check for further details in Debugging HTML Builds Documentation
To add properly AOS package add this to your page/component:
componentDidMount() {
const AOS = require('aos');
this.aos = AOS this.aos.init()
}
componentDidUpdate() {
this.aos.refresh()
}
Or using hooks:
let AOS;
useEffect(() => {
/** * Server-side rendering does not provide the 'document' object
* therefore this import is required either in useEffect or componentDidMount as they
* are exclusively executed on a client */
const AOS = require("aos");
AOS.init({ once: true, }); }, []);
useEffect(() => { if (AOS) { AOS.refresh(); } });

Related

Netlify deploy React Project failed (with error message: Command failed with exit code 1: npm run build)

Below is the message I got.
I have tried other solutions such as changing the deployed setting 'CI=npm build run' and set a new environmental variable CI false But none of them worked.
below is the version without setting the 'CI=npm build run' but set CI to false.
$ npm run build
1:51:55 PM: > anqi-portfolio#0.1.0 build
1:51:55 PM: > react-scripts build
1:51:56 PM: Creating an optimized production build...
1:51:56 PM: Failed to compile.
1:51:56 PM:
1:51:56 PM: Module not found: Error: Can't resolve '../src/pages/AboutPage' in '/opt/build/repo/src'
1:51:56 PM: ​
1:51:56 PM: "build.command" failed
1:51:56 PM: ────────────────────────────────────────────────────────────────
1:51:56 PM: ​
1:51:56 PM: Error message
1:51:56 PM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
1:51:56 PM: ​
1:51:56 PM: Error location
1:51:56 PM: In Build command from Netlify app:
1:51:56 PM: npm run build
1:51:56 PM: ​
1:51:56 PM: Resolved config
1:51:56 PM: build:
1:51:56 PM: command: npm run build
1:51:56 PM: commandOrigin: ui
1:51:56 PM: environment:
1:51:56 PM: - CI
1:51:56 PM: publish: /opt/build/repo/build
1:51:56 PM: publishOrigin: ui
1:51:57 PM: Caching artifacts
1:51:57 PM: Started saving node modules
1:51:57 PM: Finished saving node modules
1:51:57 PM: Started saving build plugins
1:51:57 PM: Finished saving build plugins
1:51:57 PM: Started saving pip cache
1:51:57 PM: Finished saving pip cache
1:51:57 PM: Started saving emacs cask dependencies
1:51:57 PM: Finished saving emacs cask dependencies
1:51:57 PM: Started saving maven dependencies
1:51:58 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:51:57 PM: Finished saving maven dependencies
1:51:57 PM: Started saving boot dependencies
1:51:57 PM: Finished saving boot dependencies
1:51:57 PM: Started saving rust rustup cache
1:51:57 PM: Finished saving rust rustup cache
1:51:57 PM: Started saving go dependencies
1:51:57 PM: Finished saving go dependencies
1:51:58 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:51:58 PM: Failing build: Failed to build site
1:51:58 PM: Finished processing build request in 30.452339066s

Build failing when deploying to netlify

Code builds without any errors or warnings in my local machine and runs with no problems at all. This is my first webpage, and I just cannot get it to deploy. I have been stuck in this step for a few days now and I am getting so tired looking at it. If anyone has an idea of that is going on I would really appreciate it. I am running MAC OS and VS CODE
2:10:21 PM: ​
2:10:21 PM: $ yarn build
2:10:22 PM: yarn run v1.22.19
2:10:22 PM: $ next build
2:10:22 PM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2:10:22 PM: info - Linting and checking validity of types...
2:10:24 PM: info - Creating an optimized production build...
2:10:26 PM: Failed to compile.
2:10:26 PM:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/hhh.png' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img100.png' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img9.jpg' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img15.png' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img11.webp' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: > Build failed because of webpack errors
2:10:26 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
2:10:26 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2:10:26 PM: ​
2:10:26 PM: ────────────────────────────────────────────────────────────────
2:10:26 PM: "build.command" failed
2:10:26 PM: ────────────────────────────────────────────────────────────────
2:10:26 PM: ​
2:10:26 PM: Error message
2:10:26 PM: Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
2:10:26 PM: ​
2:10:26 PM: Error location
2:10:26 PM: In Build command from Netlify app:
2:10:26 PM: yarn build
2:10:26 PM: ​
2:10:26 PM: Resolved config
2:10:26 PM: build:
2:10:26 PM: command: yarn build
2:10:26 PM: commandOrigin: ui
2:10:26 PM: environment:
2:10:26 PM: - NEXT_PRIVATE_TARGET
2:10:26 PM: publish: /opt/build/repo/.next
2:10:26 PM: publishOrigin: ui
2:10:26 PM: plugins:
2:10:26 PM: - inputs: {}
2:10:26 PM: origin: ui
2:10:26 PM: package: '#netlify/plugin-nextjs'
2:10:27 PM: Caching artifacts
2:10:27 PM: Started saving node modules
2:10:27 PM: Finished saving node modules
2:10:27 PM: Started saving build plugins
2:10:27 PM: Finished saving build plugins
2:10:27 PM: Started saving yarn cache
2:10:29 PM: Finished saving yarn cache
2:10:29 PM: Started saving pip cache
2:10:29 PM: Finished saving pip cache
2:10:29 PM: Started saving emacs cask dependencies
2:10:29 PM: Finished saving emacs cask dependencies
2:10:29 PM: Started saving maven dependencies
2:10:29 PM: Finished saving maven dependencies
2:10:29 PM: Started saving boot dependencies
2:10:29 PM: Finished saving boot dependencies
2:10:29 PM: Started saving rust rustup cache
2:10:29 PM: Finished saving rust rustup cache
2:10:29 PM: Started saving go dependencies
2:10:29 PM: Finished saving go dependencies
2:10:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:10:31 PM: Creating deploy upload records
2:10:31 PM: Failing build: Failed to build site
2:10:31 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:10:31 PM: Finished processing build request in 38.844689685s

Failed to compile when deploying next.js website on netlify after adding webp images

I faced a problem that the deploying next.js website on netlify is failed after I added some webp images.
7:56:07 PM: Failed to compile.
7:56:07 PM:
7:56:07 PM: ./assets/images/categories/Charitytoken.webp
7:56:07 PM: Error: Buffer has an unsupported format
7:56:07 PM: > Build error occurred
7:56:07 PM: Error: > Build failed because of webpack errors
7:56:07 PM: at /opt/build/repo/node_modules/next/dist/build/index.js:397:19
7:56:07 PM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/telemetry/trace/trace.js:60:20)
7:56:07 PM: at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:77:25)
7:56:07 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
7:56:07 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:56:07 PM: ​
7:56:07 PM: ────────────────────────────────────────────────────────────────
7:56:07 PM: "build.command" failed
7:56:07 PM: ────────────────────────────────────────────────────────────────
7:56:07 PM: ​
7:56:07 PM: Error message
7:56:07 PM: Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
7:56:07 PM: ​
7:56:07 PM: Error location
7:56:07 PM: In Build command from Netlify app:
7:56:07 PM: yarn build
7:56:07 PM: ​
7:56:07 PM: Resolved config
7:56:07 PM: build:
7:56:07 PM: command: yarn build
7:56:07 PM: commandOrigin: ui
7:56:07 PM: environment:
7:56:07 PM: - NEXT_PRIVATE_TARGET
7:56:07 PM: publish: /opt/build/repo/.next
7:56:07 PM: publishOrigin: ui
7:56:07 PM: plugins:
7:56:07 PM: - inputs: {}
7:56:07 PM: origin: ui
7:56:07 PM: package: '#netlify/plugin-nextjs'
7:56:07 PM: Caching artifacts
7:56:07 PM: Started saving node modules
7:56:07 PM: Finished saving node modules
7:56:07 PM: Started saving build plugins
7:56:07 PM: Finished saving build plugins
For avoiding such error, is there any way to handle webp images while deploying on netlify?

Posts not updated when created via Netlify CMS

I've created a new post through Netlify CMS however the posts are not updating on the Gatsby site. I thoroughly followed the add Netlify CMS to existing sites documentation and everything seems to be working fine except the posts is not showing up on my site.
Here are the links to my site with repo and the config.yml file:
My site: https://my-blogger.netlify.app/
My repo: https://github.com/mohammedasker/blogger
config.yml
backend:
name: git-gateway
branch: master
media_folder: "static/media"
public_folder: "/media"
collections:
- name: "blog"
label: "Blog"
folder: "src/content"
create: true
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
fields:
- { label: "Layout", name: "layout", widget: "hidden", default: "blog" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Slug", name: "slug", widget: "string" }
- { label: "Draft", name: "draft", widget: "boolean", default: true }
- { label: "Description", name: "description", widget: "text" }
- { label: "Publish Date", name: "date", widget: "datetime" }
- { label: "Body", name: "body", widget: "markdown" }
Additional information
I've noticed in the deploy details that the path value is null in "gatsby-node.js" and this might prevent the post from being updated. That being said, the problem continues to persist when the deploy was all green.
Build log:
8:26:23 PM: Build ready to start
8:26:25 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
8:26:25 PM: build-image tag: v3.3.20
8:26:25 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
8:26:25 PM: Fetching cached dependencies
8:26:25 PM: Starting to download cache of 139.0MB
8:26:26 PM: Finished downloading cache in 725.651881ms
8:26:26 PM: Starting to extract cache
8:26:32 PM: Finished extracting cache in 6.022644176s
8:26:32 PM: Finished fetching cache in 6.792240623s
8:26:32 PM: Starting to prepare the repo for build
8:26:32 PM: Preparing Git Reference refs/heads/master
8:26:33 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
8:26:33 PM: Starting build script
8:26:34 PM: Installing dependencies
8:26:34 PM: Python version set to 2.7
8:26:34 PM: Started restoring cached node version
8:26:36 PM: Finished restoring cached node version
8:26:37 PM: v12.18.0 is already installed.
8:26:38 PM: Now using node v12.18.0 (npm v6.14.4)
8:26:38 PM: Started restoring cached build plugins
8:26:38 PM: Finished restoring cached build plugins
8:26:38 PM: Attempting ruby version 2.7.1, read from environment
8:26:39 PM: Using ruby version 2.7.1
8:26:39 PM: Using PHP version 5.6
8:26:39 PM: 5.2 is already installed.
8:26:39 PM: Using Swift version 5.2
8:26:39 PM: Started restoring cached node modules
8:26:39 PM: Finished restoring cached node modules
8:26:39 PM: Started restoring cached yarn cache
8:26:39 PM: Finished restoring cached yarn cache
8:26:40 PM: Installing NPM modules using Yarn version 1.22.4
8:26:40 PM: yarn install v1.22.4
8:26:40 PM: [1/4] Resolving packages...
8:26:41 PM: success Already up-to-date.
8:26:41 PM: Done in 0.84s.
8:26:41 PM: NPM modules installed using Yarn
8:26:41 PM: Started restoring cached go cache
8:26:41 PM: Finished restoring cached go cache
8:26:41 PM: go version go1.14.4 linux/amd64
8:26:41 PM: go version go1.14.4 linux/amd64
8:26:41 PM: Installing missing commands
8:26:41 PM: Verify run directory
8:26:42 PM: ​
8:26:42 PM: ┌─────────────────────────────┐
8:26:42 PM: │ Netlify Build │
8:26:42 PM: └─────────────────────────────┘
8:26:42 PM: ​
8:26:42 PM: ❯ Version
8:26:42 PM: #netlify/build 3.0.1
8:26:42 PM: ​
8:26:42 PM: ❯ Flags
8:26:42 PM: deployId: 5f25a5bfbf80940007d20ec6
8:26:42 PM: mode: buildbot
8:26:42 PM: ​
8:26:42 PM: ❯ Current directory
8:26:42 PM: /opt/build/repo
8:26:42 PM: ​
8:26:42 PM: ❯ Config file
8:26:42 PM: No config file was defined: using default values.
8:26:42 PM: ​
8:26:42 PM: ❯ Context
8:26:42 PM: production
8:26:42 PM: ​
8:26:42 PM: ┌───────────────────────────────────┐
8:26:42 PM: │ 1. Build command from Netlify app │
8:26:42 PM: └───────────────────────────────────┘
8:26:42 PM: ​
8:26:42 PM: $ gatsby build
8:26:45 PM: success open and validate gatsby-configs - 0.025s
8:26:46 PM: success load plugins - 0.796s
8:26:46 PM: success onPreInit - 0.009s
8:26:46 PM: success delete html and css files from previous builds - 0.012s
8:26:46 PM: success initialize cache - 0.006s
8:26:46 PM: success copy gatsby files - 0.032s
8:26:46 PM: success onPreBootstrap - 0.007s
8:26:46 PM: success createSchemaCustomization - 0.058s
8:26:46 PM: success Checking for changed pages - 0.000s
8:26:46 PM: success source and transform nodes - 0.145s
8:26:46 PM: success building schema - 0.359s
8:26:46 PM: error Your site's "gatsby-node.js" must set the page path when creating a page.
8:26:46 PM: The page object passed to createPage:
8:26:46 PM: {
8:26:46 PM: "path": null,
8:26:46 PM: "component": "/opt/build/repo/src/templates/blog-post.js",
8:26:46 PM: "slug": "/2020-07-30-you-should-join-the-100daysofcode-challenge/",
8:26:46 PM: "context": {}
8:26:46 PM: }
8:26:46 PM: See the documentation for the "createPage" action — https://www.gatsbyjs.org/docs/actions/#createPage
8:26:46 PM: not finished createPages - 0.020s
8:26:47 PM: ​
8:26:47 PM: ┌─────────────────────────────┐
8:26:47 PM: │ "build.command" failed │
8:26:47 PM: └─────────────────────────────┘
8:26:47 PM: ​
8:26:47 PM: Error message
8:26:47 PM: Command failed with exit code 1: gatsby build
8:26:47 PM: ​
8:26:47 PM: Error location
8:26:47 PM: In Build command from Netlify app:
8:26:47 PM: gatsby build
8:26:47 PM: ​
8:26:47 PM: Resolved config
8:26:47 PM: build:
8:26:47 PM: command: gatsby build
8:26:47 PM: commandOrigin: ui
8:26:47 PM: publish: /opt/build/repo/public
8:26:47 PM: Caching artifacts
8:26:47 PM: Started saving node modules
8:26:47 PM: Finished saving node modules
8:26:47 PM: Started saving build plugins
8:26:47 PM: Finished saving build plugins
8:26:47 PM: Started saving yarn cache
8:26:47 PM: Finished saving yarn cache
8:26:47 PM: Started saving pip cache
8:26:47 PM: Finished saving pip cache
8:26:47 PM: Started saving emacs cask dependencies
8:26:47 PM: Finished saving emacs cask dependencies
8:26:47 PM: Started saving maven dependencies
8:26:47 PM: Finished saving maven dependencies
8:26:47 PM: Started saving boot dependencies
8:26:47 PM: Finished saving boot dependencies
8:26:47 PM: Started saving go dependencies
8:26:47 PM: Finished saving go dependencies
8:26:47 PM: Error running command: Build script returned non-zero exit code: 1
8:26:47 PM: Failing build: Failed to build site
8:26:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
8:26:47 PM: Finished processing build request in 22.237427248s
Updated: Added "gatsby-node.js" file
const path = require(`path`)
const { createFilePath } = require(`gatsby-source-filesystem`)
exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions
if (node.internal.type === `MarkdownRemark`) {
const slug = createFilePath({ node, getNode, basePath: `pages` })
createNodeField({
node,
name: `slug`,
value: slug,
})
}
}
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
const blogPostTemplate = path.resolve(`src/templates/blog-post.js`)
return graphql(`
{
allMarkdownRemark {
edges {
node {
frontmatter {
path
draft
date
}
fields {
slug
}
}
}
}
}
`).then(result => {
if (result.errors) {
return Promise.reject(result.errors)
}
result.data.allMarkdownRemark.edges
.filter(({ node }) => !node.frontmatter.draft)
.forEach(({ node }) => {
createPage({
path: node.frontmatter.path,
component: blogPostTemplate,
slug: node.fields.slug,
context: {},
})
})
})
}
You have to re-build to update contents, since Gatsby is a static site generator.
After only build, you could check updates because Gatsby fetch updated datas from Netlify CMS when you build.
But you can implement real-time update with Netlify CMS, you need to add markdown pages.
https://www.gatsbyjs.org/docs/sourcing-from-netlify-cms

latest changes not showing on Netlify after deployment

This is my first time deploying a react js app to Netlify and I'm facing some issues.
every time I try to push new commits to GitHub Netlify automatically deploys it but the changes don't seem to take effect for some reason.
Here's the deployment log:
2:03:20 PM: Waiting for other deploys from your team to complete
2:03:41 PM: Build ready to start
2:03:43 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
2:03:43 PM: build-image tag: v3.3.20
2:03:43 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
2:03:43 PM: Fetching cached dependencies
2:03:43 PM: Starting to download cache of 114.5MB
2:03:45 PM: Finished downloading cache in 1.515845861s
2:03:45 PM: Starting to extract cache
2:03:50 PM: Finished extracting cache in 5.156934064s
2:03:50 PM: Finished fetching cache in 6.69538965s
2:03:50 PM: Starting to prepare the repo for build
2:03:50 PM: Preparing Git Reference refs/heads/master
2:03:52 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'build/' in the Netlify UI
2:03:52 PM: Starting build script
2:03:52 PM: Installing dependencies
2:03:52 PM: Python version set to 2.7
2:03:52 PM: Started restoring cached node version
2:03:55 PM: Finished restoring cached node version
2:03:55 PM: v12.18.0 is already installed.
2:03:56 PM: Now using node v12.18.0 (npm v6.14.4)
2:03:56 PM: Started restoring cached build plugins
2:03:56 PM: Finished restoring cached build plugins
2:03:56 PM: Attempting ruby version 2.7.1, read from environment
2:03:57 PM: Using ruby version 2.7.1
2:03:57 PM: Using PHP version 5.6
2:03:57 PM: 5.2 is already installed.
2:03:57 PM: Using Swift version 5.2
2:03:57 PM: Started restoring cached node modules
2:03:57 PM: Finished restoring cached node modules
2:03:58 PM: Started restoring cached go cache
2:03:58 PM: Finished restoring cached go cache
2:03:58 PM: go version go1.14.4 linux/amd64
2:03:58 PM: go version go1.14.4 linux/amd64
2:03:58 PM: Installing missing commands
2:03:58 PM: Verify run directory
2:03:59 PM: ​
2:03:59 PM: ┌─────────────────────────────┐
2:03:59 PM: │ Netlify Build │
2:03:59 PM: └─────────────────────────────┘
2:03:59 PM: ​
2:03:59 PM: ❯ Version
2:03:59 PM: #netlify/build 3.0.1
2:03:59 PM: ​
2:03:59 PM: ❯ Flags
2:03:59 PM: deployId: 5f16bd6759d4ae00096bdb64
2:03:59 PM: mode: buildbot
2:03:59 PM: ​
2:03:59 PM: ❯ Current directory
2:03:59 PM: /opt/build/repo
2:03:59 PM: ​
2:03:59 PM: ❯ Config file
2:03:59 PM: No config file was defined: using default values.
2:03:59 PM: ​
2:03:59 PM: ❯ Context
2:03:59 PM: production
2:03:59 PM: ​
2:03:59 PM: ┌───────────────────────────────────┐
2:03:59 PM: │ 1. Build command from Netlify app │
2:03:59 PM: └───────────────────────────────────┘
2:03:59 PM: ​
2:03:59 PM: $ npm run
2:03:59 PM: Lifecycle scripts included in cortex_app:
2:03:59 PM: start
2:03:59 PM: react-scripts start
2:03:59 PM: test
2:03:59 PM: react-scripts test
2:03:59 PM: available via `npm run-script`:
2:03:59 PM: build
2:03:59 PM: react-scripts build
2:03:59 PM: eject
2:03:59 PM: react-scripts eject
2:03:59 PM: ​
2:03:59 PM: (build.command completed in 303ms)
2:03:59 PM: ​
2:03:59 PM: ┌─────────────────────────────┐
2:03:59 PM: │ Netlify Build Complete │
2:03:59 PM: └─────────────────────────────┘
2:03:59 PM: ​
2:03:59 PM: (Netlify Build completed in 322ms)
2:03:59 PM: Caching artifacts
2:03:59 PM: Started saving node modules
2:03:59 PM: Finished saving node modules
2:03:59 PM: Started saving build plugins
2:03:59 PM: Finished saving build plugins
2:03:59 PM: Started saving pip cache
2:03:59 PM: Finished saving pip cache
2:03:59 PM: Started saving emacs cask dependencies
2:03:59 PM: Finished saving emacs cask dependencies
2:03:59 PM: Started saving maven dependencies
2:03:59 PM: Finished saving maven dependencies
2:03:59 PM: Started saving boot dependencies
2:03:59 PM: Finished saving boot dependencies
2:03:59 PM: Started saving go dependencies
2:03:59 PM: Finished saving go dependencies
2:03:59 PM: Build script success
2:03:59 PM: Starting to deploy site from 'build'
2:03:59 PM: Creating deploy tree
2:03:59 PM: Creating deploy upload records
2:03:59 PM: 0 new files to upload
2:03:59 PM: 0 new functions to upload
2:03:59 PM: Starting post processing
2:03:59 PM: Post processing - HTML
2:04:00 PM: Post processing - redirect rules
2:04:00 PM: Post processing - header rules
2:04:00 PM: Post processing done
2:04:00 PM: Site is live
2:04:19 PM: Finished processing build request in 36.032433755s
the latest commit is 9421ef1 and the changes are visible on the GitHub repo. so what might be the problem in case somebody else was facing a similar issue?
It looks like your netlify build command is set to npm run, that needs to be npm run build for Netlify to know how to build your React app into a production site.
You can change that in your netlify.toml or in your Build Settings on the Netlify website.

Resources