簡體   English   中英

語法錯誤:意外令牌'<'-bundle.js not serverd

[英]SyntaxError: Unexpected token '<' - bundle.js not serverd

我在早上將新版本的react網站部署到了我們的AWS Beanstalk開發服務器上,出了點問題。 我收到了SyntaxError:部署版本中出現意外的令牌'<'。 然后,我決定部署舊版本,但是出現了同樣的錯誤。 經過大量的嘗試,我最終終止了環境並克隆了生產環境以創建新的開發服務器,但是問題仍然存在。

基本上,克隆環境會失敗,而在生產服務器上可以正常運行。

到目前為止,我還注意到的唯一其他奇怪的事情是,當我獲取wget http://phoodster-web-dev.eu-west-1.elasticbeanstalk.com/bundle.js它返回index.html而不是bundle.js文件,而我們的生產服務器可以正確執行。

知道有什么問題嗎?

更新:bundle.js看起來像index.html的原因是,因為bundle.js顯然未編譯。 在nodejs日志中,我可能已經找到了原因:

./~/react-geosuggest/module/input.js中的錯誤找不到模塊:錯誤:無法解析/ var / app / current / node_modules / react-geosuggest / module @中的模塊'react-addons-shallow-compare'。 /~/react-geosuggest/module/input.js 15:33-72

./~/react-geosuggest/module/suggest-list.js中的錯誤找不到模塊:錯誤:無法解析/ var / app / current / node_modules / react-geosuggest / module中的模塊'react-addons-shallow-compare' @ ./~/react-geosuggest/module/suggest-list.js 13:33-72

./~/react-geosuggest/module/suggest-item.js中的錯誤找不到模塊:錯誤:無法解析/ var / app / current / node_modules / react-geosuggest / module中的模塊'react-addons-shallow-compare' @ ./~/react-geosuggest/module/suggest-item.js 13:33-72

仍然很奇怪,為什么它僅在新克隆而不在主服務器上失敗。

您缺少bundle.js中的相關javascript代碼。它看起來像一個沒有內容的index.html,這可能是由於意外覆蓋文件或測試中存在一些編譯錯誤所致

編輯:

您需要以這種方式安裝節點模塊(在控制台中)

  npm i react-addons-shallow-compare

這樣就不會再失敗了,只是缺少了模塊

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM