Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to compile: Cannot find file './containers/App/App' in './src'

I have been having a hard time pushing a React.js app to Heroku because I keep getting a failed to build message with the following amplifying information.

Heroku Build Console:

-----> Build
       Running build

       > [email protected] build /tmp/build_2456efea678b82d24203cb2e2c7bcbd5
       > react-scripts build

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

       ./src/index.js
       Cannot find file './containers/App/App' in './src'.

My index.js file:

import App from './containers/App/App'
import * as serviceWorker from './serviceWorker'
import { BrowserRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import { createStore, applyMiddleware } from 'redux'
import rootReducer from './reducers'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunk from 'redux-thunk'

const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(thunk)))

const router = (
    <Provider store={store}>
        <BrowserRouter>
            <App />
        </BrowserRouter>
    </Provider>
)

File Structure:

src
  -->containers
    -->App
      -->__snapshots__
      -->App.js
      -->App.scss
      -->App.test.js
  -->index.js

I have tried deleting node_modules and reinstalling them, I have tried clearing the build cache in heroku, I have tried specifying App.js in the relative path, I have tried specifying the node version in the yml and package.json files, The Build passes locally with npm run build, I have tried just passing in each component into the router's position and I have found that all of the components work but all of the containers do not (could this be a redux issue somehow?)

I am about out of ideas :/

like image 547
Cody Price Avatar asked Apr 18 '19 22:04

Cody Price


3 Answers

You can start by clearing the cache and see if there are any files that have been renamed.

This will cache the entire directory:

git rm -r --cached .

Also, you have to add, commit and push the changes:

git add .
git commit -am 'Removing cached files'
like image 90
osvaldo carrillo Avatar answered Nov 06 '22 14:11

osvaldo carrillo


Rename containers to Containers and components to Components

like image 4
Nikita Beznosikov Avatar answered Nov 06 '22 14:11

Nikita Beznosikov


You might have changed the casing of the file names after you have commited to git. You can fix it by calling git mv path/app.js path/App.js. This explicitly changes the file name in git.

like image 3
superpringles Avatar answered Nov 06 '22 15:11

superpringles