簡體   English   中英

React引擎導致“找不到模塊”錯誤

[英]React engine is causing “Cannot find module” error

我正在使用react-engine向服務器提供對React組件的訪問權限。 使用react-engine您可以通過路由url並使用res.render來提供express反應。 為此,您需要提供文檔指定req.url的路徑。

app.use("/", function(req, res){
    return res.render(req.url, data);
})

現在,當url為/index ,它將傳遞到react-router ,並且react路由將被編譯為一個字符串,該字符串在該端點處返回。

我遇到的問題是網址中有句點。

每當get查詢( /index.html )或路由路徑本身( /index?example=foo.bar )中有/index?example=foo.bar都會出現錯誤,指出以下內容。

Cannot find module 'html'

要么

Cannot find module 'bar'

分別。

我是否必須對網址進行轉義?

res.render(req.url.replace(/\./g, ""), data)

如何擺脫Cannot find module 'extension'消息?

我還在github上的react-engine放置了一個特定的問題

不久前,我在反應引擎上建立了PR。

https://github.com/paypal/react-engine/pull/58

這里還有一個長期存在的問題:

https://github.com/paypal/react-engine/issues/52

暫無
暫無

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

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