Gatsby: Gatsby build error on Netlify

Created on 10 Jun 2019  ยท  6Comments  ยท  Source: gatsbyjs/gatsby

Summary

I am unable to deploy on Netlify! I'm getting the next error during build on Netlify, but locally everything is working.

1:28:26 PM: Executing user command: gatsby build
1:28:29 PM: success open and validate gatsby-configs โ€” 0.013 s
1:28:29 PM: warning Plugin gatsby-remark-reading-time is not compatible with your gatsby version 2.8.6 - It requires gatsby@next
1:28:30 PM: success load plugins โ€” 1.206 s
1:28:30 PM: success onPreInit โ€” 0.008 s
1:28:30 PM: success delete html and css files from previous builds โ€” 0.008 s
1:28:30 PM: success initialize cache โ€” 0.010 s
1:28:30 PM: success copy gatsby files โ€” 0.026 s
1:28:30 PM: success onPreBootstrap โ€” 0.012 s
1:28:32 PM: success source and transform nodes โ€” 2.159 s
1:28:33 PM: success building schema โ€” 0.544 s
1:28:33 PM: success createPages โ€” 0.077 s
1:28:33 PM: success createPagesStatefully โ€” 0.037 s
1:28:33 PM: success onPreExtractQueries โ€” 0.002 s
1:28:33 PM: success update schema โ€” 0.049 s
1:28:33 PM: success extract queries from components โ€” 0.149 s
1:28:37 PM: success run static queries โ€” 3.241 s โ€” 2/2 0.62 queries/second
1:28:37 PM: success run page queries โ€” 0.609 s โ€” 8/8 13.18 queries/second
1:28:37 PM: success write out page data โ€” 0.035 s
1:28:37 PM: success write out redirect data โ€” 0.056 s
1:28:46 PM: success Build manifest and related icons โ€” 0.203 s
1:28:46 PM: success onPostBootstrap โ€” 0.206 s
1:28:46 PM: info bootstrap finished - 19.729 s
1:28:57 PM: error Generating JavaScript bundles failed
1:28:57 PM: 
1:28:57 PM:   Error: ./src/components/common/index.js
1:28:57 PM:   Module not found: Error: Can't resolve './Icon' in '/opt/build/repo/src/components/common'
1:28:57 PM:   resolve './Icon' in '/opt/build/repo/src/components/common'
1:28:57 PM:     using description file: /opt/build/repo/package.json (relative path: ./src/components/common)
1:28:57 PM:       Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:       using description file: /opt/build/repo/package.json (relative path: ./src  /components/common/Icon)
1:28:57 PM:         no extension
1:28:57 PM:           Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:           /opt/build/repo/src/components/common/Icon doesn't exist
1:28:57 PM:         .mjs
1:28:57 PM:           Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:           /opt/build/repo/src/components/common/Icon.mjs doesn't exist
1:28:57 PM:         .js
1:28:57 PM:           Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:           /opt/build/repo/src/components/common/Icon.js doesn't exist
1:28:57 PM:         .jsx
1:28:57 PM:           Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:           /opt/build/repo/src/components/common/Icon.jsx doesn't exist
1:28:57 PM:         .wasm
1:28:57 PM:           Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:           /opt/build/repo/src/components/common/Icon.wasm doesn't exist
1:28:57 PM:         .json
1:28:57 PM:           Field 'browser' doesn't contain a valid alias configuration
1:28:57 PM:           /opt/build/repo/src/components/common/Icon.json doesn't exist
1:28:57 PM:         as directory
1:28:57 PM:           /opt/build/repo/src/components/common/Icon doesn't exist
1:28:57 PM:   [/opt/build/repo/src/components/common/Icon]
1:28:57 PM:   [/opt/build/repo/src/components/common/Icon.mjs]
1:28:57 PM:   [/opt/build/repo/src/components/common/Icon.js]
1:28:57 PM:   [/opt/build/repo/src/components/common/Icon.jsx]
1:28:57 PM:   [/opt/build/repo/src/components/common/Icon.wasm]
1:28:57 PM:   [/opt/build/repo/src/components/common/Icon.json]
1:28:57 PM:    @ ./src/components/common/index.js 1:0-23 1:0-23
1:28:57 PM:    @ ./src/templates/post.js
1:28:57 PM:    @ ./.cache/async-requires.js
1:28:57 PM:    @ ./.cache/production-app.js
1:28:57 PM: 
1:28:57 PM: 
1:28:57 PM:   Error: chunk component---src-pages-404-js
1:29:00 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
1:28:57 PM:   component---src-pages-404-js-03ff94967b766b7e72e5.js
1:28:57 PM:   /opt/build/repo/node_modules/gatsby/dist/utils/babel-loader.js??ref--5-0!/opt/  build/repo/src/components/common/index.js 3e038d9b3c04c3b2d2685a6ea01c0294
1:29:00 PM: Shutting down logging, 111 messages pending

Environment

System:
OS: macOS High Sierra 10.13.6
Shell: 3.0.2 - /usr/local/bin/fish
Binaries:
Node: 10.15.0 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 74.0.3729.169
Safari: 12.1.1
npmPackages:
gatsby: ^2.8.6 => 2.8.6
gatsby-image: ^2.1.2 => 2.1.2
gatsby-plugin-google-analytics: ^2.0.20 => 2.0.20
gatsby-plugin-manifest: ^2.1.1 => 2.1.1
gatsby-plugin-offline: ^2.1.1 => 2.1.1
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-root-import: ^2.0.5 => 2.0.5
gatsby-plugin-sass: ^2.0.11 => 2.0.11
gatsby-plugin-sharp: ^2.1.3 => 2.1.3
gatsby-remark-external-links: 0.0.4 => 0.0.4
gatsby-remark-images: ^3.0.14 => 3.0.14
gatsby-remark-prismjs: ^3.2.11 => 3.2.11
gatsby-remark-reading-time: ^1.0.1 => 1.0.1
gatsby-source-filesystem: ^2.0.38 => 2.0.38
gatsby-source-graphql: ^2.0.19 => 2.0.19
gatsby-transformer-remark: ^2.3.12 => 2.3.12
gatsby-transformer-sharp: ^2.1.21 => 2.1.21

File contents

package.json:

{
  "private": true,
  "version": "0.1.0",
  "name": "byurhanbeyzat-com",
  "description": "Byurhan's personal website.",
  "author": "Byurhan Beyzat <[email protected]>",
  "repository": "https://github.com/byurhanbeyzat/byurhanbeyzat-com",
  "license": "MIT",
  "scripts": {
    "dev": "GATSBY_GRAPHQL_IDE=playground gatsby develop -o",
    "build": "gatsby build",
    "serve": "gatsby serve",
    "lint": "eslint '*.{js,jsx}'",
    "format": "prettier --write {*.js,**/*.{js,jsx}}"
  },
  "dependencies": {
    "classnames": "^2.2.6",
    "dotenv": "^8.0.0",
    "gatsby": "^2.8.6",
    "gatsby-image": "^2.1.2",
    "gatsby-plugin-google-analytics": "^2.0.20",
    "gatsby-plugin-manifest": "^2.1.1",
    "gatsby-plugin-offline": "^2.1.1",
    "gatsby-plugin-react-helmet": "^3.0.12",
    "gatsby-plugin-root-import": "^2.0.5",
    "gatsby-plugin-sass": "^2.0.11",
    "gatsby-plugin-sharp": "^2.1.3",
    "gatsby-remark-external-links": "0.0.4",
    "gatsby-remark-images": "^3.0.14",
    "gatsby-remark-prismjs": "^3.2.11",
    "gatsby-remark-reading-time": "^1.0.1",
    "gatsby-source-filesystem": "^2.0.38",
    "gatsby-source-graphql": "^2.0.19",
    "gatsby-transformer-remark": "^2.3.12",
    "gatsby-transformer-sharp": "^2.1.21",
    "node-sass": "^4.12.0",
    "prismjs": "^1.16.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-helmet": "^5.2.1"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^4.3.0",
    "eslint-plugin-import": "^2.17.3",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.13.0",
    "prettier": "^1.18.2"
  }
}

gatsby-config.js:

const config = require(`./config`)

require('dotenv').config({ path: `${process.env.NODE_ENV}.env` })

module.exports = {
  siteMetadata: config.siteMetadata,
  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    `gatsby-plugin-sass`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images/`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `content`,
        path: `${__dirname}/src/content/`,
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              quality: 90,
              maxWidth: 1280,
              linkImagesToOriginal: true,
            },
          },
          {
            resolve: `gatsby-remark-external-links`,
            options: {
              target: `_blank`,
              rel: `noopener noreferrer`,
            },
          },
          `gatsby-remark-reading-time`,
          `gatsby-remark-prismjs`,
        ],
      },
    },
    {
      resolve: `gatsby-source-graphql`,
      options: {
        typeName: 'GitHub',
        fieldName: 'github',
        url: 'https://api.github.com/graphql',
        headers: {
          Authorization: `bearer ${process.env.GITHUB_TOKEN}`,
        },
        fetchOptions: {},
      },
    },
    {
      resolve: `gatsby-plugin-google-analytics`,
      options: {
        trackingId: process.env.GA_TRACKING,
        head: true,
      },
    },
    {
      resolve: `gatsby-plugin-root-import`,
      options: {
        images: `${__dirname}/src/images`,
        styles: `${__dirname}/src/styles`,
        utilities: `${__dirname}/src/utilities`,
        components: `${__dirname}/src/components`,
        common: `${__dirname}/src/components/common`,
      },
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: config.siteManifest,
    },
    `gatsby-plugin-offline`,
  ],
}

gatsby-node.js:

const path = require(`path`)
const { createFilePath } = require(`gatsby-source-filesystem`)

exports.createPages = ({ graphql, actions: { createPage } }) => {
  return graphql(`
    {
      posts: allMarkdownRemark(
        filter: { fileAbsolutePath: { regex: "/posts/" } }
        sort: { fields: [frontmatter___date], order: DESC }
        limit: 1000
      ) {
        edges {
          node {
            fields {
              path
            }
            frontmatter {
              title
            }
          }
        }
      }
    }
  `).then(result => {
    if (result.errors) {
      throw result.errors
    }

    // Create blog posts pages.
    const posts = result.data.posts.edges

    posts.forEach(({ node }) => {
      createPage({
        path: node.fields.path,
        component: path.resolve(`./src/templates/post.js`),
        context: { slug: node.fields.path },
      })
    })

    return null
  })
}

exports.onCreateNode = ({ node, getNode, actions: { createNodeField } }) => {
  if (node.internal.type === `MarkdownRemark`) {
    const value = createFilePath({ node, getNode })
    createNodeField({
      name: `path`,
      node,
      value,
    })
  }
}

gatsby-browser.js: N/A
gatsby-ssr.js: N/A

question or discussion

Most helpful comment

This seems like a case of

  • either not commited Icon file
  • or using wrong case when importing - linux (used by netlify build) is case sensitve

All 6 comments

This seems like a case of

  • either not commited Icon file
  • or using wrong case when importing - linux (used by netlify build) is case sensitve

@pieh Thank you! I'm updated folder names and I don't know why but icon folder is not updated on Github it stays 'icon' instead of 'Icon'.

@byurhanbeyzat You'll have to delete the 'icon' file first and then add the 'Icon' (with the first letter capitalised).

@kogal In first commits it was icon then I renamed it to Icon locally but git did not recognise letter upgrade. I've resolved this problem running git mv icon tmp && git mv tmp Icon

I am having the same problem. I am not really sure where is the

issue.

12:05:39 PM: Build ready to start
12:05:41 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
12:05:41 PM: build-image tag: v3.3.2
12:05:41 PM: buildbot version: ef8d0929ed0baabafd8bbb7d0b021e1fc24180c0
12:05:42 PM: Fetching cached dependencies
12:05:42 PM: Failed to fetch cache, continuing with build
12:05:42 PM: Starting to prepare the repo for build
12:05:42 PM: No cached dependencies found. Cloning fresh repo
12:05:42 PM: git clone https://github.com/DubaniWarrior/wisdom-sagesse
12:05:43 PM: Preparing Git Reference refs/heads/master
12:05:43 PM: Starting build script
12:05:43 PM: Installing dependencies
12:05:45 PM: Downloading and installing node v10.16.0...
12:05:45 PM: Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz...
12:05:45 PM:

#

12:05:45 PM: 46.3%
12:05:45 PM:

#

12:05:45 PM: ################################ 100.0%
12:05:45 PM: Computing checksum with sha256sum
12:05:45 PM: Checksums matched!
12:05:48 PM: Now using node v10.16.0 (npm v6.9.0)
12:05:48 PM: Attempting ruby version 2.6.2, read from environment
12:05:49 PM: Using ruby version 2.6.2
12:05:50 PM: Using PHP version 5.6
12:05:50 PM: Started restoring cached node modules
12:05:50 PM: Finished restoring cached node modules
12:05:50 PM: Installing NPM modules using NPM version 6.9.0
12:06:22 PM: > [email protected] install /opt/build/repo/node_modules/sharp
12:06:22 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
12:06:23 PM: info
12:06:23 PM: sharp
12:06:23 PM: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
12:06:25 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js
12:06:25 PM: > node scripts/postinstall || echo "ignore"
12:06:25 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
12:06:25 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
12:06:25 PM: > https://opencollective.com/core-js
12:06:25 PM: > https://www.patreon.com/zloirock
12:06:25 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
12:06:25 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js-pure
12:06:25 PM: > node scripts/postinstall || echo "ignore"
12:06:25 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
12:06:25 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
12:06:25 PM: > https://opencollective.com/core-js
12:06:25 PM: > https://www.patreon.com/zloirock
12:06:25 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
12:06:25 PM: > [email protected] postinstall /opt/build/repo/node_modules/gatsby-telemetry
12:06:25 PM: > node src/postinstall.js
12:06:26 PM: > [email protected] postinstall /opt/build/repo/node_modules/cwebp-bin
12:06:26 PM: > node lib/install.js
12:06:26 PM: โœ” cwebp pre-build test passed successfully
12:06:26 PM: > [email protected] postinstall /opt/build/repo/node_modules/mozjpeg
12:06:26 PM: > node lib/install.js
12:06:27 PM: โœ” mozjpeg pre-build test passed successfully
12:06:27 PM: > [email protected] postinstall /opt/build/repo/node_modules/pngquant-bin
12:06:27 PM: > node lib/install.js
12:06:27 PM: โœ” pngquant pre-build test passed successfully
12:06:27 PM: > [email protected] postinstall /opt/build/repo/node_modules/styled-components
12:06:27 PM: > node ./scripts/postinstall.js || exit 0
12:06:27 PM: Use styled-components at work? Consider supporting our development efforts at https://opencollective.com/styled-components
12:06:30 PM: npm WARN
12:06:30 PM: optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
12:06:30 PM: npm WARN
12:06:30 PM: notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:06:30 PM: added 2009 packages from 1056 contributors and audited 35481 packages in 38.895s
12:06:30 PM: found 0 vulnerabilities
12:06:30 PM: NPM modules installed
12:06:30 PM: Started restoring cached go cache
12:06:30 PM: Finished restoring cached go cache
12:06:30 PM: unset GOOS;
12:06:30 PM: unset GOARCH;
12:06:30 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
12:06:30 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
12:06:30 PM: go version >&2;
12:06:30 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
12:06:30 PM: go version go1.12 linux/amd64
12:06:30 PM: Installing missing commands
12:06:30 PM: Verify run directory
12:06:30 PM: Executing user command: gatsby build
12:06:33 PM: success open and validate gatsby-configs โ€” 0.119
12:06:34 PM: success load plugins โ€” 1.373
12:06:34 PM: success onPreInit โ€” 0.013
12:06:34 PM: success delete html and css files from previous builds โ€” 0.016
12:06:34 PM: success initialize cache โ€” 0.019
12:06:34 PM: success copy gatsby files โ€” 0.033
12:06:34 PM: success onPreBootstrap โ€” 0.025
12:06:34 PM: Starting to fetch data from Contentful
12:06:34 PM: Fetching default locale
12:06:34 PM: error
12:06:34 PM: Accessing your Contentful space failed.
12:06:34 PM: Try setting GATSBY_CONTENTFUL_OFFLINE=true to see if we can serve from cache.
12:06:34 PM: Authorization error. Check if accessToken and environment are correct
12:06:34 PM: Used options:
12:06:34 PM: spaceId: "**lne"
12:06:34 PM: accessToken: "
********************8FEo" - Check if setting is correct
12:06:34 PM: host (default value): "cdn.contentful.com"
12:06:34 PM: environment (default value): "master" - Check if setting is correct
12:06:34 PM: downloadLocal (default value): false
12:06:34 PM: localeFilter (default value): [Function]
12:06:34 PM: forceFullSync (default value): false
12:06:34 PM: See our docs page for more info on this error: https://gatsby.dev/issue-how-to
12:06:35 PM: Skipping functions preparation step: no functions directory set
12:06:35 PM: Caching artifacts
12:06:35 PM: Started saving node modules
12:06:35 PM: Finished saving node modules
12:06:35 PM: Started saving pip cache
12:06:35 PM: Finished saving pip cache
12:06:35 PM: Started saving emacs cask dependencies
12:06:35 PM: Finished saving emacs cask dependencies
12:06:35 PM: Started saving maven dependencies
12:06:35 PM: Finished saving maven dependencies
12:06:35 PM: Started saving boot dependencies
12:06:35 PM: Finished saving boot dependencies
12:06:35 PM: Started saving go dependencies
12:06:35 PM: Finished saving go dependencies
12:06:38 PM: Error running command: Build script returned non-zero exit code: 1
12:06:38 PM: Failing build: Failed to build site
12:06:38 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
12:06:38 PM: Finished processing build request in 56.233021925s

@pieh was correct:

or using wrong case when importing - linux (used by netlify build) is case sensitve

I had recently renamed layout.js to Layout.js but Git on macOS didn't track this change. I had to rename it to something else, commit it to git, rename back to Layout.js for Git to track the name with the correct case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalinchernev picture kalinchernev  ยท  3Comments

rossPatton picture rossPatton  ยท  3Comments

dustinhorton picture dustinhorton  ยท  3Comments

3CordGuy picture 3CordGuy  ยท  3Comments

KyleAMathews picture KyleAMathews  ยท  3Comments