Could not find a required file. Name: index.js

EDIT Solved with this

Publish directory: public```

So I doubled checked and made sure my Gatsby site can run locally with gatsby develop, build, serve. All work. So then I go to Netlify and try to deploy and I get this error

1:33:41 PM:   Name: index.js
1:33:41 PM:   Searched in: /opt/build/repo/src```

My index.js is located inside of my src folder —> pages folder --index.js file

Since I thought they were saying my index.js file should be outside of the pages folder and located in my src folder so src folder → index.js file.

I placed index.js outside of my pages folder and inside of my src folder and then I get an error.
I have confirmed index.js belongs in my pages folder but then I keep getting this error with Netlify

2:32:03 PM: Waiting for other deploys from your team to complete
2:37:40 PM: Build ready to start
2:37:42 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
2:37:42 PM: build-image tag: v3.6.1
2:37:42 PM: buildbot version: 4c3d8713ccd4c98ab9180f79a013d42d2076d9ff
2:37:42 PM: Fetching cached dependencies
2:37:42 PM: Failed to fetch cache, continuing with build
2:37:42 PM: Starting to prepare the repo for build
2:37:42 PM: No cached dependencies found. Cloning fresh repo
2:37:42 PM: git clone GitHub - Camus1859/portfolio2
2:37:44 PM: Preparing Git Reference refs/heads/source
2:37:45 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘build’ versus ‘build/’ in the Netlify UI
2:37:45 PM: Starting build script
2:37:45 PM: Installing dependencies
2:37:45 PM: Python version set to 2.7
2:37:46 PM: v12.18.0 is already installed.
2:37:47 PM: Now using node v12.18.0 (npm v6.14.4)
2:37:47 PM: Started restoring cached build plugins
2:37:47 PM: Finished restoring cached build plugins
2:37:47 PM: Attempting ruby version 2.7.1, read from environment
2:37:48 PM: Using ruby version 2.7.1
2:37:48 PM: Using PHP version 5.6
2:37:48 PM: Started restoring cached node modules
2:37:48 PM: Finished restoring cached node modules
2:37:48 PM: Installing NPM modules using NPM version 6.14.4
2:38:54 PM: > sharp@0.27.2 install /opt/build/repo/node_modules/sharp
2:38:54 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
2:38:56 PM: info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.5/libvips-8.10.5-linux-x64.tar.br
2:38:58 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-register/node_modules/core-js
2:38:58 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
2:38:58 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
2:38:58 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
2:38:58 PM: > core-js@3.9.0 postinstall /opt/build/repo/node_modules/core-js
2:38:58 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
2:38:59 PM: > core-js-pure@3.9.0 postinstall /opt/build/repo/node_modules/core-js-pure
2:38:59 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
2:39:01 PM: > uglifyjs-webpack-plugin@0.4.6 postinstall /opt/build/repo/node_modules/uglifyjs-webpack-plugin
2:39:01 PM: > node lib/post_install.js
2:39:02 PM: > gatsby-telemetry@1.10.1 postinstall /opt/build/repo/node_modules/gatsby-telemetry
2:39:02 PM: > node src/postinstall.js || true
2:39:02 PM: > mozjpeg@7.0.0 postinstall /opt/build/repo/node_modules/mozjpeg
2:39:02 PM: > node lib/install.js
2:39:02 PM: :heavy_check_mark: mozjpeg pre-build test passed successfully
2:39:02 PM: > pngquant-bin@6.0.0 postinstall /opt/build/repo/node_modules/pngquant-bin
2:39:02 PM: > node lib/install.js
2:39:03 PM: :heavy_check_mark: pngquant pre-build test passed successfully
2:39:03 PM: > gatsby-cli@2.19.2 postinstall /opt/build/repo/node_modules/gatsby-cli
2:39:03 PM: > node scripts/postinstall.js
2:39:03 PM: > gatsby@2.32.8 postinstall /opt/build/repo/node_modules/gatsby
2:39:03 PM: > node scripts/postinstall.js
2:39:07 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
2:39:07 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:39:07 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
2:39:07 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:39:07 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/react-scripts/node_modules/fsevents):
2:39:07 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:39:07 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
2:39:07 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
2:39:07 PM: added 3699 packages from 1719 contributors and audited 3714 packages in 77.787s
2:39:11 PM: 186 packages are looking for funding
2:39:11 PM: run npm fund for details
2:39:11 PM: found 39 vulnerabilities (32 low, 3 moderate, 4 high)
2:39:11 PM: run npm audit fix to fix them, or npm audit for details
2:39:11 PM: NPM modules installed
2:39:11 PM: Started restoring cached go cache
2:39:11 PM: Finished restoring cached go cache
2:39:11 PM: go version go1.14.4 linux/amd64
2:39:11 PM: go version go1.14.4 linux/amd64
2:39:11 PM: Installing missing commands
2:39:11 PM: Verify run directory
2:39:13 PM: ​
2:39:13 PM: ────────────────────────────────────────────────────────────────
2:39:13 PM: Netlify Build
2:39:13 PM: ────────────────────────────────────────────────────────────────
2:39:13 PM: ​
2:39:13 PM: ❯ Version
2:39:13 PM: @netlify/build 9.4.0
2:39:13 PM: ​
2:39:13 PM: ❯ Flags
2:39:13 PM: deployId: 603a9e33d682055096888548
2:39:13 PM: mode: buildbot
2:39:13 PM: ​
2:39:13 PM: ❯ Current directory
2:39:13 PM: /opt/build/repo
2:39:13 PM: ​
2:39:13 PM: ❯ Config file
2:39:13 PM: No config file was defined: using default values.
2:39:13 PM: ​
2:39:13 PM: ❯ Context
2:39:13 PM: production
2:39:13 PM: ​
2:39:13 PM: ────────────────────────────────────────────────────────────────
2:39:13 PM: 1. Build command from Netlify app
2:39:13 PM: ────────────────────────────────────────────────────────────────
2:39:13 PM: ​
2:39:13 PM: $ npm run build
2:39:13 PM: > gatsby-starter-default@0.1.0 build /opt/build/repo
2:39:13 PM: > react-scripts build
2:39:14 PM: Could not find a required file.
2:39:14 PM: Name: index.js
2:39:14 PM: Searched in: /opt/build/repo/src
2:39:14 PM: npm ERR! code ELIFECYCLE
2:39:14 PM: npm ERR! errno 1
2:39:14 PM: npm ERR! gatsby-starter-default@0.1.0 build: react-scripts build
2:39:14 PM: npm ERR! Exit status 1
2:39:14 PM: npm ERR!
2:39:14 PM: npm ERR! Failed at the gatsby-starter-default@0.1.0 build script.
2:39:14 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2:39:14 PM: npm ERR! A complete log of this run can be found in:
2:39:14 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-02-27T19_39_14_646Z-debug.log
2:39:14 PM: ​
2:39:14 PM: ────────────────────────────────────────────────────────────────
2:39:14 PM: “build.command” failed
2:39:14 PM: ────────────────────────────────────────────────────────────────
2:39:14 PM: ​
2:39:14 PM: Error message
2:39:14 PM: Command failed with exit code 1: npm run build
2:39:14 PM: ​
2:39:14 PM: Error location
2:39:14 PM: In Build command from Netlify app:
2:39:14 PM: npm run build
2:39:14 PM: ​
2:39:14 PM: Resolved config
2:39:14 PM: build:
2:39:14 PM: command: npm run build
2:39:14 PM: commandOrigin: ui
2:39:14 PM: publish: /opt/build/repo/build
2:39:14 PM: Caching artifacts
2:39:14 PM: Started saving node modules
2:39:14 PM: Finished saving node modules
2:39:14 PM: Started saving build plugins
2:39:14 PM: Finished saving build plugins
2:39:14 PM: Started saving pip cache
2:39:14 PM: Finished saving pip cache
2:39:14 PM: Started saving emacs cask dependencies
2:39:14 PM: Finished saving emacs cask dependencies
2:39:14 PM: Started saving maven dependencies
2:39:14 PM: Finished saving maven dependencies
2:39:14 PM: Started saving boot dependencies
2:39:14 PM: Finished saving boot dependencies
2:39:14 PM: Started saving rust rustup cache
2:39:14 PM: Finished saving rust rustup cache
2:39:14 PM: Started saving go dependencies
2:39:14 PM: Finished saving go dependencies
2:39:17 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:39:17 PM: Failing build: Failed to build site
2:39:18 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
2:39:18 PM: Finished processing build request in 1m35.836586421s

I made some progress with your issue, though couldn’t fix it.

First, I changed your package.json to:

{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "A simple starter to get up and developing quickly with Gatsby",
  "version": "0.1.0",
  "author": "Kyle Mathews <mathews.kyle@gmail.com>",
  "dependencies": {
    "@babel/core": "7.13.8",
    "@babel/plugin-proposal-decorators": "7.13.5",
    "@babel/plugin-transform-react-jsx": "7.12.17",
    "@babel/plugin-transform-react-jsx-self": "7.12.13",
    "@babel/preset-env": "7.13.8",
    "@babel/preset-react": "7.12.13",
    "@headlessui/react": "0.3.1",
    "autoprefixer": "10.2.4",
    "babel-core": "6.26.3",
    "babel-loader": "8.2.2",
    "babel-preset-env": "1.7.0",
    "babel-preset-gatsby": "0.12.2",
    "gatsby": "2.32.8",
    "gatsby-cli": "2.19.2",
    "gatsby-image": "2.11.0",
    "gatsby-plugin-manifest": "2.12.1",
    "gatsby-plugin-offline": "3.10.2",
    "gatsby-plugin-postcss": "3.7.0",
    "gatsby-plugin-react-helmet": "3.10.0",
    "gatsby-plugin-react-svg": "3.0.0",
    "gatsby-plugin-remote-images": "2.2.0",
    "gatsby-plugin-sharp": "2.14.3",
    "gatsby-source-filesystem": "2.11.1",
    "gatsby-source-graphql": "2.14.0",
    "gatsby-source-remote-file": "0.2.3",
    "gatsby-transformer-sharp": "2.12.0",
    "gh-pages": "3.1.0",
    "html-react-parser": "1.2.4",
    "postcss": "8.2.6",
    "prettier": "2.2.1",
    "prop-types": "15.7.2",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-helmet": "6.1.0",
    "react-scripts": "4.0.3",
    "tailwindcss": "2.0.3",
    "webpack": "5.24.2"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "0BSD",
  "scripts": {
    "deploy:github": "npm run build && node ./scripts/deploy-github",
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Basically, I updated all the dependencies and moved the ones from dev to normal dependencies. This might have fixed some errors as Netlify probably doesn’t install dev dependencies. I also changed your build command to gatsby build. Now I get the error:

ERROR #98123  WEBPACK
Generating JavaScript bundles failed
Cannot read property 'includes' of undefined

Sadly this doesn’t mention the source of the error so it’s hard for me to fix it. Even then, I searched your code for includes and commented all lines in contactspg.js and projectspg.js that included this word. It still fails. Maybe this can get you going.

Hey @Camus1859

Does this mean this is solved or are you still in need of some help?