2015-07-10 67 views
1

我正在使用react-engine爲服務器提供訪問反應組件的權限。使用react-engine,您可以通過路由url並使用res.render來提供express反應。爲此,您需要提供文檔指定的路徑req.urlReact引擎導致「找不到模塊」錯誤

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

現在,當URL是/index將被傳遞到react-router和作出反應,在該端點返回的路線會被編譯成一個字符串。

我遇到的問題是當URL有一段時間。

每當get查詢(/index.html)或路徑路徑本身(/index?example=foo.bar)中存在句點時,出現錯誤提示以下內容。

Cannot find module 'html' 

Cannot find module 'bar' 

分別。

我是否必須將期間轉移到網址?

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

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

我也把a specific issue herereact-engine在github上。

+0

我挖掘到這一點,我想可能有一些兩者並與德快遞視圖引擎[點擊這裏] (https://github.com/paypal/react-engine/blob/master/lib/expressView.js#L23)。當任何路由包含一段時間時發生錯誤:http://stackoverflow.com/questions/16111386/node-js-cannot-find-module-html – ThomasReggi

+0

我認爲它的發生是因爲'express/lib/view'認爲文件被傳遞的是一個普通的視圖模板,比如'index.jade',它的功能是解析擴展以找到它使用的模板庫。https://github.com/strongloop/express/blob/master/lib/view.js #L76-L79 – ThomasReggi

回答