简体   繁体   中英

React app failed to compile on Heroku - import error?

This is the error what I get when trying to deploy my React app on Heroku:

-----> Build
       Running build

       > projectx@0.1.0 build /tmp/build_f8319236f3ff554c9b2b847b7cd7e6f7
       > react-scripts build

       Creating an optimized production build...
       Failed to compile.

       ./src/components/application/App.js
       Cannot find file '../landing/Home' in './src/components/application'.

I'm not sure why it's searching for my Home component in the App.js' local folder (which is components/application )

This is a fragment from my App.js. It works fine locally.

import DashboardLayout from '../layout/DashboardLayout';
import Home from '../landing/Home';
import Counter from '../dashboard/Counter';
import Login from '../landing/Login';
import Register from '../landing/Register';
    ...
 return (
    <AuthContext.Provider value={{ authTokens, setAuthTokens: setTokens }}>
      <Router>
        <Switch>
          <PublicRoute exact path='/' component={Home} layout={LandingLayout} />

This is my folder structure:

在此处输入图片说明

What am I missing here? Should I use another mode of importing?

Got the problem, my landing/ folder was actually Landing/ in a previous version on Git. Turns out git is not case-sensitive and does not detect folder case-sensitive renames.

So I had to rename the folder in git as well with:

git mv Landing/ tmp
git mv tmp/ landing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM