## Express 4.17 原本在 Express 4.17 中,載入 Handlebars 的方式如下: ```javascript const exphbs = require('express-handlebars') app.engine('handlebars', exphbs({ defaultLayout: 'main' })) app.set('view engine', 'handlebars') ``` ## Express 4.18 不過到了 Express 4.18 時,如果還使用上面的方式,就會跳出型別錯誤。 ``` TypeError: exphbs is not a function ``` 依據[這裡的方式](https://stackoverflow.com/questions/69959820/typeerror-exphbs-is-not-a-function),必須在上段第二行的 exphbs 加上 .engine: ```javascript app.engine('handlebars', exphbs.engine({ defaultLayout: 'main' })) ``` 這樣就會回復正常。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up