bundle.js cannot be found

bundle.js cannot be found

本文关键字:found be cannot js bundle      更新时间:2023-09-26

我正在使用react/router 2.0的browserHistory和lite-server构建一个应用程序。Router代码如下

const appRouter = (
    <Router history={browserHistory}>
        <Route path="/" component={App}>
            <IndexRoute component={LandingPage}/>
            <Route path="/posts" component={Posts}/>
            <Route path="/posts/:postId" component={Post}/>
        </Route>
    </Router>
);

错误是X GET http://localhost:3000/posts/lib/bundle.js

此错误仅在url为http://localhost:3000/posts/somePostId并且刷新页面或

后发生。

lib/bundle.js文件应该从根目录'/'加载,但它试图从'/posts/'加载。

我刚从hashHistory切换到browserHistory,切换后发生错误

因为你有一条路由<Route path="/posts/:postId" component={Post}/>

与bundle.js: http://localhost:3000/posts/lib/bundle.js的路径相匹配,请尝试将js文件移到其他文件夹或使用其他路径