编译失败:在“./src"中找不到文件“./containers/App/App" [英] Failed to compile: Cannot find file './containers/App/App' in './src'

查看:112
本文介绍了编译失败:在“./src"中找不到文件“./containers/App/App"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直很难将 React.js 应用程序推送到 Heroku,因为我不断收到带有以下放大信息的构建失败消息.

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 构建控制台:

Heroku Build Console:

-----> Build
       Running build

       > veterinfo@0.1.0 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'.

我的 index.js 文件:

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>
)

文件结构:

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

我尝试删除 node_modules 并重新安装它们,我曾尝试清除 heroku 中的构建缓存,我尝试在相对路径中指定 App.js,我尝试在 yml 和 package.json 文件中指定节点版本,Build 在本地通过 npm run build 传递,我尝试将每个组件传递到路由器的位置,我发现所有组件都可以工作,但所有容器都没有(这可能是 redux 问题吗?)

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?)

我已经没有想法了:/

推荐答案

您可以先清除缓存,看看是否有任何已重命名的文件.

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

这将缓存整个目录:

git rm -r --cached .

此外,您必须添加、提交和推送更改:

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

git add .
git commit -am 'Removing cached files'

这篇关于编译失败:在“./src"中找不到文件“./containers/App/App"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆