美文网首页
SAP Spartacus 服务器端渲染找不到 index 视图

SAP Spartacus 服务器端渲染找不到 index 视图

作者: 华山令狐冲 | 来源:发表于2021-10-04 09:07 被阅读0次

我基于 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) [<root>]
at ServerResponse.render (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186292:7) [<root>]
at C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:315912:13 [<root>]
at Layer.handle [as handle_request] (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187201:5) [<root>]
at next (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187435:13) [<root>]
at Route.dispatch (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187410:3) [<root>]
at Layer.handle [as handle_request] (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187201:5) [<root>]
at C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186714:22 [<root>]
at param (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186787:14) [<root>]
at param (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186798:14) [<root>]
at Function.process_params (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186843:3) [<root>]
at next (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:186708:10) [<root>]
at expressInit (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:184672:5) [<root>]
at Layer.handle [as handle_request] (C:\Code\SPA\spartacus\dist\storefrontapp-server\main.js:187201:5) [<root>]

原因是我忘了首先构建 Storefrontapp,因为即使服务器端渲染时,还是会从 dist 文件夹里读取 index 视图。

因此,首先执行 yarn build,对 storefrontapp 进行构建:

dist/storefrontapp 文件夹下构建出来的 JavaScript 文件动态刷新:

之后问题解决:

更多Jerry的原创文章,尽在:"汪子熙":


相关文章

网友评论

      本文标题:SAP Spartacus 服务器端渲染找不到 index 视图

      本文链接:https://www.haomeiwen.com/subject/ydhqiltx.html