Gatsby run build - error at createPages that is working ok on gatsby develop

PLEASE help us help you by writing a good post!

Hi, my site name is : sleepy-rosalind-fabd9f
I’m having errors at building stage - on develop stage it works fine - according the following BUILD LOG


9:54:01 PM: ────────────────────────────────────────────────────────────────
9:54:01 PM:   Netlify Build                                                 
9:54:01 PM: ────────────────────────────────────────────────────────────────
9:54:01 PM: ​
9:54:01 PM: ❯ Version
9:54:01 PM:   @netlify/build 26.4.0
9:54:01 PM: ​
9:54:01 PM: ❯ Flags
9:54:01 PM:   baseRelDir: true
9:54:01 PM:   buildId: 622a9d52ef81e6000927ec34
9:54:01 PM:   deployId: 622a9d52ef81e6000927ec36
9:54:01 PM: ​
9:54:01 PM: ❯ Current directory
9:54:01 PM:   /opt/build/repo
9:54:01 PM: ​
9:54:01 PM: ❯ Config file
9:54:01 PM:   No config file was defined: using default values.
9:54:01 PM: ​
9:54:01 PM: ❯ Context
9:54:01 PM:   production
9:54:01 PM: ​
9:54:01 PM: ❯ Installing plugins
9:54:01 PM:    - @netlify/plugin-gatsby@2.1.2
9:54:11 PM: ​
9:54:11 PM: ❯ Loading plugins
9:54:11 PM:    - @netlify/plugin-gatsby@2.1.2 from Netlify app
9:54:13 PM: ​
9:54:13 PM: ────────────────────────────────────────────────────────────────
9:54:13 PM:   1. @netlify/plugin-gatsby (onPreBuild event)                  
9:54:13 PM: ────────────────────────────────────────────────────────────────
9:54:13 PM: ​
9:54:13 PM: No Gatsby cache found. Building fresh.
9:54:13 PM: Please install `gatsby-plugin-netlify` and enable it in your gatsby-config.js. https://www.gatsbyjs.com/plugins/gatsby-plugin-netlify/
9:54:13 PM: ​
9:54:13 PM: (@netlify/plugin-gatsby onPreBuild completed in 10ms)
9:54:13 PM: ​
9:54:13 PM: ────────────────────────────────────────────────────────────────
9:54:13 PM:   2. Build command from Netlify app                             
9:54:13 PM: ────────────────────────────────────────────────────────────────
9:54:13 PM: ​
9:54:13 PM: $ npm run build
9:54:13 PM: > unique-webs@1.0.0 build
9:54:13 PM: > gatsby build
9:54:16 PM: success compile gatsby files - 1.099s
9:54:16 PM: success load gatsby config - 0.033s
9:54:17 PM: success load plugins - 0.856s
9:54:17 PM: success onPreInit - 0.010s
9:54:17 PM: success initialize cache - 0.496s
9:54:18 PM: success copy gatsby files - 0.377s
9:54:18 PM: success Compiling Gatsby Functions - 0.187s
9:54:18 PM: success onPreBootstrap - 0.195s
9:54:19 PM: success loading DatoCMS schema - 0.765s
9:54:19 PM: success createSchemaCustomization - 0.857s
9:54:22 PM: success loading DatoCMS content - 2.933s
9:54:22 PM: success Checking for changed pages - 0.000s
9:54:22 PM: success source and transform nodes - 3.285s
9:54:22 PM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
9:54:24 PM: success building schema - 1.413s
9:54:24 PM: [
9:54:24 PM:   [Object: null prototype] { slug: 'pro2' },
9:54:24 PM:   [Object: null prototype] { slug: 'pro3' },
9:54:24 PM:   [Object: null prototype] { slug: 'pro1' }
9:54:24 PM: ]
9:54:24 PM: error "gatsby-node.js" threw an error while running the createPages lifecycle:
9:54:24 PM: Cannot find module './src/components/proyectos.js'
9:54:24 PM: Require stack:
9:54:24 PM: - /opt/build/repo/gatsby-node.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plugin.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/services/index.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
9:54:24 PM: - /opt/build/repo/node_modules/gatsby/cli.js
9:54:24 PM:   33 |         actions.createPage({
9:54:24 PM:   34 |             path: proyecto.slug,
9:54:24 PM: > 35 |             component: require.resolve('./src/components/proyectos.js'),
9:54:24 PM:      |                                ^
9:54:24 PM:   36 |             context: {
9:54:24 PM:   37 |                 slug:proyecto.slug
9:54:24 PM:   38 |             }
9:54:24 PM: 
9:54:24 PM: 
9:54:24 PM:   Error: Cannot find module './src/components/proyectos.js'
9:54:24 PM:   Require stack:
9:54:24 PM:   - /opt/build/repo/gatsby-node.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/resolve-module-exports.js  - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/validate.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-plugins/resolve-plug  in.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-themes/index.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/load-config/index.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/services/initialize.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/services/index.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/bootstrap/index.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/commands/build.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/create-cli.j  s
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/node_modules/gatsby-cli/lib/index.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/dist/bin/gatsby.js
9:54:24 PM:   - /opt/build/repo/node_modules/gatsby/cli.js
9:54:24 PM:   
9:54:24 PM:   - loader:933 Function.Module._resolveFilename
9:54:24 PM:     node:internal/modules/cjs/loader:933:15
9:54:24 PM:   
9:54:24 PM:   - helpers:108 Function.resolve
9:54:24 PM:     node:internal/modules/cjs/helpers:108:19
9:54:24 PM:   
9:54:24 PM:   - gatsby-node.js:35 
9:54:24 PM:     /opt/build/repo/gatsby-node.js:35:32
9:54:24 PM:   
9:54:24 PM:   - Array.forEach
9:54:24 PM:   
9:54:24 PM:   - gatsby-node.js:32 Object.exports.createPages
9:54:24 PM:     /opt/build/repo/gatsby-node.js:32:15
9:54:24 PM:   
9:54:24 PM:   - task_queues:96 processTicksAndRejections
9:54:24 PM:     node:internal/process/task_queues:96:5
9:54:24 PM:   
9:54:24 PM:   - api-runner-node.js:462 runAPI
9:54:24 PM:     [repo]/[gatsby]/src/utils/api-runner-node.js:462:16
9:54:24 PM:   
9:54:24 PM: 
9:54:24 PM: failed createPages - 0.314s
9:54:24 PM: ​
9:54:24 PM: ────────────────────────────────────────────────────────────────
9:54:24 PM:   "build.command" failed                                        
9:54:24 PM: ────────────────────────────────────────────────────────────────
9:54:24 PM: ​
9:54:24 PM:   Error message
9:54:24 PM:   Command failed with exit code 1: npm run build
9:54:24 PM: ​
9:54:24 PM:   Error location
9:54:24 PM:   In Build command from Netlify app:
9:54:24 PM:   npm run build
9:54:24 PM: ​
9:54:24 PM:   Resolved config
9:54:24 PM:   build:
9:54:24 PM:     command: npm run build
9:54:24 PM:     commandOrigin: ui
9:54:24 PM:     publish: /opt/build/repo/public
9:54:24 PM:     publishOrigin: ui
9:54:24 PM:   plugins:
9:54:24 PM:     - inputs: {}
9:54:24 PM:       origin: ui
9:54:24 PM:       package: '@netlify/plugin-gatsby'
9:54:25 PM: Caching artifacts
9:54:25 PM: Started saving node modules
9:54:25 PM: Finished saving node modules
9:54:25 PM: Started saving build plugins
9:54:25 PM: Finished saving build plugins
9:54:25 PM: Started saving pip cache
9:54:25 PM: Finished saving pip cache
9:54:25 PM: Started saving emacs cask dependencies
9:54:25 PM: Finished saving emacs cask dependencies
9:54:25 PM: Started saving maven dependencies
9:54:25 PM: Finished saving maven dependencies
9:54:25 PM: Started saving boot dependencies
9:54:25 PM: Finished saving boot dependencies
9:54:25 PM: Started saving rust rustup cache
9:54:25 PM: Finished saving rust rustup cache
9:54:25 PM: Started saving go dependencies
9:54:25 PM: Finished saving go dependencies
9:54:30 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:54:30 PM: Creating deploy upload records
9:54:30 PM: Failing build: Failed to build site
9:54:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:54:30 PM: Finished processing build request in 1m47.399108276s

Thanks for the support

Hey @Vincenzo_Delre

Seems there is a missing component. Or perhaps it is a matter of case sensitivity (e.g. proyectos.js is different to proyectOs.js).

1 Like

hi there,

a little more on what coel said:

Can you give this a read through and let us know if that fixes the issue?

Hi, thanks for the reply but it was not related with a " missing component or perhaps it is a matter of case sensitivity".

The issue has been solved moving the two files from component folder to a new templates folder. Maybe is a particular case relative to gatsby builds?

You could find the reply that helped me on the following link:

1 Like

Thanks so much for coming back and sharing this resource! It will definitely be beneficial for future Forums members who encounter something similar.

Happy building :rocket:

1 Like