Heroku找不到任何模块



我正在尝试使用meteor和Heroku开发一个Web应用程序。当我在本地运行我的代码时,一切都很好,但是一旦我在 Heroku 上部署它,我就会得到:

找不到模块"./导航栏/导航栏.js

或者如果我在代码中摆脱了导航栏:

找不到模块"./组件/应用程序">

我的项目文件夹如下所示:

project
client
main.css
main.html
main.js
component
App.js
Games.js
Home.js
Workbench.js
navbar
NavBar.js
Server
main.js

这是我的代码:

主.js

import React from 'react';
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
import App from './component/App';
Meteor.startup(() => {
render(<App />, document.getElementById('root'));
});

应用.js

import React from 'react';
import {Container} from 'reactstrap';
import {BrowserRouter as Router, Route} from 'react-router-dom';
import Workbench from './Workbench'
import NavBar from './navbar/NavBar.js'
export default class App extends React.Component {
render(){
return(
<Router>
<div>
<NavBar/>
<Container fluid={true}>
<Route path='/' component={Workbench}/>
</Container>
</div>
</Router>
)
}
}

导航栏.js

import React from 'react';
import {nav} from 'react-bootstrap';
export default class NavBar extends React.Component {
constructor(props){
super(props);
this.state = {
gameList: [{}],
gamesVisibility: false
}
}
render() {
const {gameList, gameVisibility} = this.state;
return (
<div className="sidenav">
<h2 className="sidenav-header"><a href="/">Test project</a></h2>
<ul>
<li onClick={() => this.setState({gameVisibility: !gameVisibility})}> <a className="SideNavTitle">Games</a> {this.renderArrow(gameVisibility)} </li>
{this.renderCollection(gameVisibility, gameList)}
<li className="SideNavItem"><a>Channel</a></li>
<li className="SideNavItem"><a>About</a></li>
</ul>
</div>
);
}
renderCollection(visibility, collection){
if (visibility){
return collection.map((game) => <li id = 'test' className="SideNavSubItem"><a>{game.name}</a></li>)
}
else{
return;
}
}
renderArrow(visibility){
if (visibility){
return <i className="fa fa-arrow-down" aria-hidden="true" style={{color: 'white'}}/>
}
else{
return <i className="fa fa-arrow-right" aria-hidden="true" style={{color: 'white'}}/>
}
}
}

我使用heroku run bashcat NavBar.js来确认我的文件在 heroku 上,如这篇文章中所建议的那样。这有点奇怪,因为代码在本地完美运行

编辑:在Heroku上的构建成功,当我尝试加载页面时会显示这些错误。

经过一些搜索,我发现在heroku上,我有一个组件文件夹和一个组件文件夹。不知道为什么,因为我的流星项目中只有 1 个文件夹组件。用heroku run bash来找到我的问题。

我假设您的项目文件夹包含三个子文件夹(客户端,组件,服务器(。 在您的主文件中.js文件使用:

import App from '../component/App'

您使用单个"."搜索服务器文件夹中的组件文件夹。 您需要使用双">

."

相关内容

最新更新