SAP Spartacus 服务器端渲染找不到 index 视图的问题
我基于 SAP Spartacus 源代碼級別 4.0 版本進行 SSR 調試時,遇到如下錯誤:在 dist/storefrontapp 文件夾下面,找不到 index 視圖:
Error: Failed to lookup view “index” in views directory “C:\Code\SPA\spartacus\dist\storefrontapp”
at Function.render (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:184430:17) []
at ServerResponse.render (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186292:7) []
at C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:315912:13 []
at Layer.handle [as handle_request] (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187201:5) []
at next (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187435:13) []
at Route.dispatch (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187410:3) []
at Layer.handle [as handle_request] (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187201:5) []
at C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186714:22 []
at param (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186787:14) []
at param (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186798:14) []
at Function.process_params (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186843:3) []
at next (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186708:10) []
at expressInit (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:184672:5) []
at Layer.handle [as handle_request] (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187201:5) []
原因是我忘了首先構建 Storefrontapp,因為即使服務器端渲染時,還是會從 dist 文件夾里讀取 index 視圖。
因此,首先執行 yarn build,對 storefrontapp 進行構建:
dist/storefrontapp 文件夾下構建出來的 JavaScript 文件動態刷新:
之后問題解決:
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的SAP Spartacus 服务器端渲染找不到 index 视图的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 普及16GB不爆显存!A卡性价比被严重低
- 下一篇: word如何统计纯汉字个数(如何将ans