I need help with this guys. Error: No default engine was specified and no extension was provided."

I’ve been stuck with this error for days now.
“Error: No default engine was specified and no extension was provided.”

I get this whenever I try to render an ejs file or pug file.
I could use some help.


const express = require('express');
const expressLayouts = require('express-ejs-layouts');

const app = express();


// Ejs 
app.use(expressLayouts);
app.set('veiw engine', 'ejs')

// routes
app.use('/', require('./routes/index'));
app.use('/users', require('./routes/users'));

const PORT = process.env.PORT || 5000;

app.listen(PORT, console.log(`server started on port ${PORT}`));


const express = require('express');
const router = express.Router();

router.get('/', (req, res) => res.render('welcome'));

module.exports = router;

// I have a welcome.ejs file in my veiws folder.

Welcome, Gabriel.

Something you might want to try is first setting the engine, then using the express-ejs-layouts library:

app.set('view engine', 'ejs');
app.use(expressLayouts);

Otherwise, some more of the error could be useful.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hope this helps

1 Like

Thanks soo much sky for making the code easier to read.
I just tried your tip but it still gave me the same error.

Here are the rest of the error.

Error: No default engine was specified and no extension was provided.
at new View (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\view.js:61:11)
at Function.render (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\application.js:570:12)
at ServerResponse.render (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\response.js:1012:7)
at ServerResponse.res.render (C:\Users\HP\Desktop\node_passport\node_modules\express-ejs-layouts\lib\express-layouts.js:77:18)
at C:\Users\HP\Desktop\node_passport\routes\index.js:4:35
at Layer.handle [as handle_request] (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\index.js:281:22

Thanks soo much for making my post much readable.

It tried what you said but it keeps giving me the error.

Here is the rest of the error.

Error: No default engine was specified and no extension was provided.
    at new View (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\view.js:61:11)
    at Function.render (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\application.js:570:12)
    at ServerResponse.render (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\response.js:1012:7)
    at ServerResponse.res.render (C:\Users\HP\Desktop\node_passport\node_modules\express-ejs-layouts\lib\express-layouts.js:77:18)
    at C:\Users\HP\Desktop\node_passport\routes\index.js:4:35
    at Layer.handle [as handle_request] (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\HP\Desktop\node_passport\node_modules\express\lib\router\index.js:281:22

Are you sure you spelt view correctly…

Yeah, I made sure they are all in lower case.

I am pointing out the misspelt word 'veiw engine' in the original code. Have you corrected this?

Would you mind sharing a link to your code? Do you have a repo with this?

Oh, my bad… just saw that.
I got a different error this time.

I’ll be sharing the link in a bit.
you’ve been so helpful.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.