H
H
Hiroshima2020-09-12 07:03:18
Node.js
Hiroshima, 2020-09-12 07:03:18

Why can't the index view be found?

I'm getting an error when going to " localhost:3000 " it says this:
5f5c455545473058050777.png

Translation into Russian:

Could not find the view "index" in the view directory "C:\Users\User\Desktop\ac\views"
Error: Could not find the view "index" in the views directory "C:\Users\User\Desktop\ac\views"
in Function.render (C:\Users\User\Desktop\ac\node_modules\express\lib\application.js:580:17)
in ServerResponse.render (C:\Users\User\Desktop\ac\node_modules\express\lib\response.js:1008:7)
in C:\Users\User\Desktop\acc\routes\index.js:23: nine
in Layer.handle [as handle_request] (C:\Users\User\Desktop\ac\node_modules\express\lib\router\layer.js:95:5)
to the following (C:\Users\User\Desktop\ac\ node_modules\express\lib\router\route.js:137:13)
in Route.dispatch (C:\Users\User\Desktop\acc\node_modules\express\lib\router\route.js:112:3)
in Layer .handle [as handle_request] (C:\Users\User\Desktop\ac\node_modules\express\lib\router\layer.js:95:5)
in C:\Users\User\Desktop\ac\node_modules\express\ lib\router\index.js:281:22
in Function.process_params (C:\Users\User\Desktop\acc\node_modules\express\lib\router\index.js:335:12)
to the following (C:\Users\User\Desktop\ac\node_modules\express\lib\router\index.js:275:10)
to Function.handle (C:\Users\User\Desktop\acc\node_modules\express\ lib\router\index.js:174:3)
on router (C:\Users\User\Desktop\acc\node_modules\express\lib\router\index.js:47:12)
in Layer.handle [as handle_request] (C:\Users\User\Desktop\acc\node_modules\express\lib\router\layer.js:95:5)
to trim_prefix (C:\Users\User\Desktop\acc\node_modules\express\lib\router\ index.js:317:13)
to C:\Users\User\Desktop\acc\node_modules\express\lib\router\index.js:284:7
in Function.process_params (C:\Users\User\Desktop\acc\node_modules\express\lib\router\index.js:335:12)

I have the "index" view in folders:
5f5c4638795e9102525953.png

I tried pasting the original "index.jade" " and everything works with him, and if I put "index.hbs" then he cannot find this file. I thought that I should not have "handlebars", I tried to install it, the problem remained.

here is what is in router/index.js
5f5c480c8113c238285432.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cython, 2020-09-12
@Hiroshima

Have you set the view engine for handlebars? Try to pass to render not index, but index.hbs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question