2

我有一个在前端使用早午餐、卓别林和咖啡脚本的应用程序。Brunch 构建应用程序时没有任何错误。但是,当我这样做brunch watch --server并导航到时http://localhost:3333,会生成错误并且页面永远不会加载。

这以前工作得很好。diff显示存储库中没有会导致行为变化的变化。当我了解开发人员时,我还检查了前端代码的早期版本。服务器正在工作,但它们都给出了相同的错误。我尝试删除构建的代码并完全重建,但这也无济于事。

我想这一定是我在一个未跟踪的文件中所做的事情,但对于我的生活,我找不到它。这是 chrome 错误消息的输出:

Resource interpreted as Stylesheet but transferred with MIME type text/html:       "http://localhost:3333/pub/css/app.css". localhost/:10
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3333/pub/js/vendor.js". localhost/:11
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3333/pub/js/app.js". localhost/:20
Uncaught SyntaxError: Unexpected token < vendor.js:1
Uncaught SyntaxError: Unexpected token < app.js:1
Uncaught ReferenceError: require is not defined (index):21
(anonymous function) (index):21

中的违规行index似乎是

<script>require('initialize');</script>

这条线与其他类似配置的完美运行的项目没有变化。我认为这可能是愚蠢的,但它只是模糊到网络搜索没有太大帮助。希望其他人遇到过这个问题。

我能做些什么来诊断问题或解决这个问题?

4

1 回答 1

2

您必须确认,但我相信您的 JavaScript 和样式表会出现 404 错误,因此它们会返回描述 404 错误的 HTML 页面。这就是为什么那行 JavaScript 出错的原因 - 它取决于app.js未加载的代码。

确保路径正确,即将您的浏览器指向http://localhost:3333/pub/css/app.css并确认您从您的网络服务器获得一个 CSS 文件而不是 404。如果你得到一个 404,这意味着你必须更新hrefCSS 和srcJS,或者确保 Brunch 将文件放置在它们应该在的位置。

于 2014-02-17T02:45:00.897 回答