SAP Spartacus 服务器端渲染找不到 index 视图的问题
我基于 SAP Spartacus 源代碼級(jí)別 4.0 版本進(jìn)行 SSR 調(diào)試時(shí),遇到如下錯(cuò)誤:在 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) []
原因是我忘了首先構(gòu)建 Storefrontapp,因?yàn)榧词狗?wù)器端渲染時(shí),還是會(huì)從 dist 文件夾里讀取 index 視圖。
因此,首先執(zhí)行 yarn build,對(duì) storefrontapp 進(jìn)行構(gòu)建:
dist/storefrontapp 文件夾下構(gòu)建出來(lái)的 JavaScript 文件動(dòng)態(tài)刷新:
之后問(wèn)題解決:
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的SAP Spartacus 服务器端渲染找不到 index 视图的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 普及16GB不爆显存!A卡性价比被严重低
- 下一篇: 有用的Chrome扩展介绍 - Octo