我發現了一個Error: cannot find module 'hogan'
當我發送給在這裏的CoffeeScript實現Node.js的服務器發出請求:快遞+整合+霍根:'錯誤:無法找到模塊「法眼」`與代碼直接從鞏固文檔
https://gist.github.com/wmayner/306c89d7f8fbeed3f098
我已經安裝了依賴關係hogan.js
,consolidate
和express
。
我已經從consolidate
的文檔(轉載如下)幾乎完全轉載了示例代碼,所以我無法查看此錯誤來自哪裏。它看起來應該起作用。
var express = require('express')
, cons = require('consolidate')
, app = express();
// assign the swig engine to .html files
app.engine('html', cons.swig);
// set .html as the default extension
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
我也嘗試宣告`霍根=需要( 'hogan.js')」作爲一個依賴。
任何人都有一個想法,爲什麼發生這種情況?
注:要點上面從consolidate
文檔不同之處在於我設置view engine
到hogan
,而不是html
。這是因爲我寧願使用.hogan
而不是.html
作爲我的模板文件擴展名(我試過.html
,我得到相同的錯誤)。
但引擎是'hogan'',所以這實際上是我已經試過的要點'app.engine'html',引擎[引擎] \ app.set'視圖引擎',引擎(我確實希望使用'.hogan'而不是'.html')。 – Will 2013-03-14 13:43:36
試試這個要點:https://gist.github.com/robertklep/5161641 – robertklep 2013-03-14 14:16:35
完美!謝謝。我沒有意識到'app.engine'的第一個參數也是模板的文件擴展名,我沒有注意到你在編輯中將它改爲'hogan' - 只看到了第二行。我的錯! – Will 2013-03-14 15:33:14