I don't know why it gives this error. I have also set view engine
to hbs
using app.set()
, also defined path of views
(path is correct, no error there). But it still says cannot find module hbs
(it is already installed) when I try to render.
You can see that I am using get()
request to render()
the index.hbs
file inside Views
folder. Why is it showing this error?
....It's somewhat silly of me, but it was because of another node_modules
outside the project directory ExpressProject
. You can see that there is another node_modules
(in the bottom) outside ExpressProject
. But what I don't get here now, is that why is the outer node_module
affecting ExpressProject
directory?
It has it's own node_modules
, and I am also running the server from ExpressProject
directory, not from outside of it.
Run npm i --save express-handlebars. that should do the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.