I am trying to deploy my app to Heroku, it works in local but no luck online. I deleted and reinstalled node modules.
I had another error quite related to this (file not found same names etc) I changed the relative paths thinking that would fix the issue but I am getting nothing to come out of it
The error is:
Cannot find file './Components/SearchBar/SearchBar'
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import SearchBar from './Components/SearchBar/SearchBar'
import BusinessList from './Components/BusinessList/BusinessList'
import Business from './Components/Business/Business'
import Yelp from './Components/Util/Yelp'
I expected to not pull an error for something so simple, I've poured over the file and folder names and it just is not making sense.
PS I think it's probably unconnected I have const yelpApiKey=process.env.yelpApiKey for my heroku to connect to my API key (typed inside my account)
Deploy Your Code To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.
Sometimes installing a dependency or running a build locally completes successfully, and when it gets to Heroku, the build will fail. If you run into an issue where a dependency only fails on Heroku, it's recommended to spin up a one-off dyno to debug the script.
There are some errors which only occur when the app is rebooting so you will need to restart the app to see these log messages appear. For most apps, we also recommend enabling one of the free logging addons from https://elements.heroku.com/addons#logging to make sure that your historical log data is being saved.
Thank you @Jason for asking this question and @Rakesh for answering.
I deployed create-react-app project on Heroku then I encountered a similar error where failed to build my project. the error was routes.js failed to import signup.js
Heroku log
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=false
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 10.16.3
engines.npm (package.json): unspecified (use default)
Resolving node version 10.16.3...
Downloading and installing node 10.16.3...
Using default npm version: 6.9.0
-----> Restoring cache
Caching has been disabled because NODE_MODULES_CACHE=false
-----> Installing dependencies
Installing node modules (package.json + package-lock)
> [email protected] postinstall /tmp/build_5d506b6dfc93b7f4b6575e02cc682130/node_modules/babel-runtime/node_modules/core-js
> node scripts/postinstall || echo "ignore"
> [email protected] postinstall /tmp/build_5d506b6dfc93b7f4b6575e02cc682130/node_modules/core-js
> node scripts/postinstall || echo "ignore"
added 1507 packages from 719 contributors and audited 905071 packages in 35.746s
found 0 vulnerabilities
-----> Build
Running build
> [email protected] build /tmp/build_5d506b6dfc93b7f4b6575e02cc682130
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/routes.js // my beautiful error here
Cannot find file './Components/User/signup/signup.js' in './src'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.ynm0W/_logs/2019-09-30T15_24_32_571Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Heroku deploy projects on Linux servers, it means it is case sensitive if you make mistake the build will fail. I advise sticking with lowercase when naming files and directories.
my project structure
|root
|src
| componets
| user
| signup
|routes
|index.js
After I correct mistakes, I still had the same error. so why? I did not notice Git does not push the change. When you only rename the directory and even if you do git add, git commit and git push Git sometimes does not consider the changes. I advise after change go to the website to verify.
when deploying to Heroku please deploy only the base branch. for Example Master or develop. I realized every time I deployed my feature branch, Heroku automatic detect my base branch which was develop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With