安装并运行keystone.js之后可能导致此错误的原因是什么?

时间:2016-06-19 21:40:26

标签: javascript mean-stack keystonejs

我运行了keystone的默认安装,除了连接到我自己的mongodb之外,没有改变任何文件

在我的浏览器中,我看到了:

抱歉,加载页面时出错(500)

路径必须是字符串。收到['templates','templates / views']

`
zerp:keystone-yo asdf$ nodemon
[nodemon] 1.9.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node keystone.js`

------------------------------------------------
KeystoneJS Started:
keystone is ready on port 3000
------------------------------------------------

Error thrown for request: /
TypeError: Path must be a string. Received [ 'templates', 'templates/views' ]
    at assertPath (path.js:7:11)
    at Object.relative (path.js:1228:5)
    at ExpressHandlebars.renderView (/Users/asdf/Desktop/keystone-yo/node_modules/express-handlebars/lib/express-handlebars.js:192:43)
    at View.render (/Users/asdf/Desktop/keystone-yo/node_modules/express/lib/view.js:126:8)
    at tryRender (/Users/asdf/Desktop/keystone-yo/node_modules/express/lib/application.js:639:10)
    at EventEmitter.render (/Users/asdf/Desktop/keystone-yo/node_modules/express/lib/application.js:591:3)
    at ServerResponse.render (/Users/asdf/Desktop/keystone-yo/node_modules/express/lib/response.js:960:7)
    at View.<anonymous> (/Users/asdf/Desktop/keystone-yo/node_modules/keystone/lib/view.js:337:13)
    at /Users/asdf/Desktop/keystone-yo/node_modules/keystone/lib/view.js:372:3
    at /Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:52:16
    at /Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:269:32
    at /Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:44:16
    at /Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:726:13
    at /Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:52:16
    at async.forEachOf.async.eachOf (/Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:236:30)
    at _parallel (/Users/asdf/Desktop/keystone-yo/node_modules/async/lib/async.js:717:9)
GET / 500 12.613 m`

1 个答案:

答案 0 :(得分:1)

我发现的问题是在 keystone.js 内部,方法keystone.init()期待 String 而不是 Array 。将标有'views': ['templates', 'templates/views'],的行更改为'views': 'templates/views',。希望这可以解决您的问题。