Dobrý den jsem v expressu a node.js nováček a zamrzl jsem hned u prvního problému. Mám kód:
// JavaScript source code
const express = require('express');
const pug = require('pug');
const app = express();
app.set('view engine', 'pug');
app.set('views', 'views');
app.get('/', (req, res) => {
res.render(index.pug);
});
app.listen(3000, () => console.log('Listening on port 3000'));
hází to chybu:
ReferenceError: index is not defined
at C:\Users\User\node.js\express3.js:8:16
at Layer.handle [as handle_request] (C:\Users\User\node.js\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\User\node.js\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\User\node.js\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\User\node.js\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\User\node.js\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\User\node.js\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\User\node.js\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\User\node.js\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request] (C:\Users\User\node.js\node_modules\express\lib\router\layer.js:95:5)
index.pug je v adrasáři view a stejně to nefunguje . Díky za nakopnutí.