【发布时间】:2016-05-20 14:51:16
【问题描述】:
当运行ember build --environment=production 时,一切似乎都编译得很好。将文件放入服务器上的dist/ 也可以,但是当我单击页面上的链接时,出现以下错误:
vendor-ef159bc….js:11 Error while processing route: account Unexpected token < in JSON at position 0 SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (native)
at ae.parseJSON (http://localhost:8000/assets/vendor-ef159bc608efff575c24c5e13c2d1218.js:3:12644)
at W (http://localhost:8000/assets/vendor-ef159bc608efff575c24c5e13c2d1218.js:1:15665)
at n (http://localhost:8000/assets/vendor-ef159bc608efff575c24c5e13c2d1218.js:3:13996)
at XMLHttpRequest.<anonymous> (http://localhost:8000/assets/vendor-ef159bc608efff575c24c5e13c2d1218.js:3:20168)`.
我做错了什么?
【问题讨论】:
-
你能提供一个非工作项目吗?
-
通常在期待 JSON 而看到
Unexpected token < in JSON at position 0时,这表明您正在检索 HTML 而不是 JSON。当您收到此错误时,我会使用 REST 客户端来检索该 URL,这应该会为您提供有关为什么会发生这种情况的线索。 -
Wells 是
vendor.js文件。所以它可能是js。但我的意思是一个 git repo,这个问题是可以重现的。 -
嗯,奇怪的是它在开发模式下工作,而不是在为生产构建它时
-
是的。在生产模式下不起作用。面临同样的问题。有什么解决办法吗?
标签: javascript json ember.js routing