Search code examples
reactjsdeploymentnetlify

Error when trying to deploy refactored app on Netlify


I've just refactored my app by creating a folder for each component with its .js and .scss file and on local it works fine (even the npm run build command). The problem is now it gives me an error when I try to deploy it. It says

5:25:44 PM: ./src/Components/restaurants/RestaurantInfo/RestaurantInfo.js
5:25:44 PM: Cannot find file '../../util/Review' in './src/Components/restaurants/RestaurantInfo'.

it doesn't find it because ./src/Components/restaurants/RestaurantInfo is now just a folder and it should check ./src/Components/restaurants/RestaurantInfo/RestaurantInfo instead.

I've checked all the paths and are correct, as I said on local everything works as it should but clearly something is wrong and I can't figure it out.

Here's the its url: https://restaurant-finder-redux.netlify.app/ Github repository: https://github.com/mugg84/RestaurantFinderRedux.git and the full error:

5:25:41 PM: Build ready to start
5:25:43 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
5:25:43 PM: build-image tag: v3.3.20
5:25:43 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
5:25:43 PM: Fetching cached dependencies
5:25:43 PM: Starting to download cache of 254.8KB
5:25:43 PM: Finished downloading cache in 74.189736ms
5:25:43 PM: Starting to extract cache
5:25:43 PM: Failed to fetch cache, continuing with build
5:25:43 PM: Starting to prepare the repo for build
5:25:44 PM: No cached dependencies found. Cloning fresh repo
5:25:44 PM: git clone [email protected]:mugg84/RestaurantFinderRedux
5:25:45 PM: Preparing Git Reference refs/heads/master
5:25:47 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'C:\Users\Turi\Desktop\project\RestaurantsRedux\build' in the Netlify UI
5:25:47 PM: Starting build script
5:25:47 PM: Installing dependencies
5:25:47 PM: Python version set to 2.7
5:25:48 PM: v12.18.0 is already installed.
5:25:49 PM: Now using node v12.18.0 (npm v6.14.4)
5:25:49 PM: Started restoring cached build plugins
5:25:49 PM: Finished restoring cached build plugins
5:25:49 PM: Attempting ruby version 2.7.1, read from environment
5:25:51 PM: Using ruby version 2.7.1
5:25:51 PM: Using PHP version 5.6
5:25:51 PM: 5.2 is already installed.
5:25:51 PM: Using Swift version 5.2
5:25:51 PM: Started restoring cached node modules
5:25:51 PM: Finished restoring cached node modules
5:25:51 PM: Installing NPM modules using NPM version 6.14.4
5:26:28 PM: > [email protected] install /opt/build/repo/node_modules/node-sass
5:26:28 PM: > node scripts/install.js
5:26:29 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
5:26:29 PM: Download complete
5:26:29 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
5:26:29 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
5:26:30 PM: > [email protected] postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:30 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:30 PM: > [email protected] postinstall /opt/build/repo/node_modules/core-js-pure
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:31 PM: > [email protected] postinstall /opt/build/repo/node_modules/node-sass
5:26:31 PM: > node scripts/build.js
5:26:31 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
5:26:31 PM: Testing binary
5:26:31 PM: Binary is fine
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/webpack-dev-server/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/watchpack-chokidar2/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/jest-haste-map/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: added 1778 packages from 828 contributors and audited 1782 packages in 40.593s
5:26:35 PM: 60 packages are looking for funding
5:26:35 PM:   run `npm fund` for details
5:26:35 PM: found 4985 low severity vulnerabilities
5:26:35 PM:   run `npm audit fix` to fix them, or `npm audit` for details
5:26:35 PM: NPM modules installed
5:26:35 PM: Started restoring cached go cache
5:26:35 PM: Finished restoring cached go cache
5:26:35 PM: go version go1.14.4 linux/amd64
5:26:35 PM: go version go1.14.4 linux/amd64
5:26:35 PM: Installing missing commands
5:26:35 PM: Verify run directory
5:26:37 PM: ​
5:26:37 PM: ┌─────────────────────────────┐
5:26:37 PM: │        Netlify Build        │
5:26:37 PM: └─────────────────────────────┘
5:26:37 PM: ​
5:26:37 PM: ❯ Version
5:26:37 PM:   @netlify/build 3.0.1
5:26:37 PM: ​
5:26:37 PM: ❯ Flags
5:26:37 PM:   deployId: 5f19ba059db363022d8ef5d1
5:26:37 PM:   mode: buildbot
5:26:37 PM: ​
5:26:37 PM: ❯ Current directory
5:26:37 PM:   /opt/build/repo
5:26:37 PM: ​
5:26:37 PM: ❯ Config file
5:26:37 PM:   /opt/build/repo/netlify.toml
5:26:37 PM: ​
5:26:37 PM: ❯ Context
5:26:37 PM:   production
5:26:37 PM: ​
5:26:37 PM: ┌───────────────────────────────────┐
5:26:37 PM: │ 1. Build command from Netlify app │
5:26:37 PM: └───────────────────────────────────┘
5:26:37 PM: ​
5:26:37 PM: $ npm run build
5:26:37 PM: > [email protected] build /opt/build/repo
5:26:37 PM: > react-scripts build
5:26:38 PM: Creating an optimized production build...
5:26:44 PM: Failed to compile.
5:26:44 PM: 
5:26:44 PM: ./src/Components/restaurants/RestaurantInfo/RestaurantInfo.js
5:26:44 PM: Cannot find file '../../util/Review' in './src/Components/restaurants/RestaurantInfo'.
5:26:44 PM: npm ERR! code ELIFECYCLE
5:26:44 PM: npm ERR! errno 1
5:26:44 PM: npm ERR! [email protected] build: `react-scripts build`
5:26:44 PM: npm ERR! Exit status 1
5:26:44 PM: npm ERR!
5:26:44 PM: npm ERR! Failed at the [email protected] build script.
5:26:44 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:26:44 PM: npm ERR! A complete log of this run can be found in:
5:26:44 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-07-23T16_26_44_363Z-debug.log
5:26:44 PM:   
5:26:44 PM:   If the build failed with a warning about "process.env.CI = true", this is due to "create-react-app" treating warnings as errors when in CI. In order to fix this problem, please either:
5:26:44 PM:     - Fix the issues highlighted by the warnings above.
5:26:44 PM:     - Or modify the "scripts.build" command in your "package.json" from "react-scripts build" to "CI= react-scripts build"
5:26:44 PM:   More information can be found at https://docs.netlify.com/configure-builds/troubleshooting-tips/#build-fails-on-warning-message
5:26:44 PM: ​
5:26:44 PM: ┌─────────────────────────────┐
5:26:44 PM: │   "build.command" failed    │
5:26:44 PM: └─────────────────────────────┘
5:26:44 PM: ​
5:26:44 PM:   Error message
5:26:44 PM:   Command failed with exit code 1: npm run build
5:26:44 PM: ​
5:26:44 PM:   Error location
5:26:44 PM:   In Build command from Netlify app:
5:26:44 PM:   npm run build
5:26:44 PM: ​
5:26:44 PM:   Resolved config
5:26:44 PM:   build:
5:26:44 PM:     command: npm run build
5:26:44 PM:     commandOrigin: ui
5:26:44 PM:     environment:
5:26:44 PM:       - REACT_APP_GOOGLE_API_KEY
5:26:44 PM:       - REACT_APP_MAILCHIMP_URL
5:26:44 PM:       - REACT_APP_YELP_API_KEY
5:26:44 PM:     publish: /opt/build/repo/build
5:26:44 PM: Caching artifacts
5:26:44 PM: Started saving node modules
5:26:44 PM: Finished saving node modules
5:26:44 PM: Started saving build plugins
5:26:44 PM: Finished saving build plugins
5:26:44 PM: Started saving pip cache
5:26:44 PM: Finished saving pip cache
5:26:44 PM: Started saving emacs cask dependencies
5:26:44 PM: Finished saving emacs cask dependencies
5:26:44 PM: Started saving maven dependencies
5:26:44 PM: Finished saving maven dependencies
5:26:44 PM: Started saving boot dependencies
5:26:44 PM: Finished saving boot dependencies
5:26:44 PM: Started saving go dependencies
5:26:44 PM: Finished saving go dependencies
5:26:47 PM: Error running command: Build script returned non-zero exit code: 1
5:26:47 PM: Failing build: Failed to build site
5:26:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
5:26:47 PM: Finished processing build request in 1m4.47397412s

Thanks for your help!


Solution

  • The issue was a discrepancy between the repository name of one folder and the local one, specifically the folder util.

    In the repository it was uppercase, Util, while locally util and that was causing the issue.

    That explains why locally npm run build was working bit it wasn't in deployment.