Unable to set default directory for views
See original GitHub issueHello, I am unable to set default views
directory.
OS: Ubuntu 15.04 Node: 4.0.0
I am in app directory (…).
When running node server/server.js
, it ignores
app.set('views', path.join(__dirname, 'views'));
from server.js
and tries to load
.../views/layouts/main.handlebars
instead .../server/views/layouts/main.handlebars
.
└── server
├── server.js
└── views
├── home.handlebars
└── layouts
└── main.handlebars
server.js
'use strict';
var path = require('path');
var express = require('express');
var exphbs = require('express-handlebars');
var app = express();
// Rendering engine setup
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');
app.set('views', path.join(__dirname, 'views'));
console.log(path.join(__dirname, 'views'));
// Routes
app.get('/', function (req, res) {
res.render('home');
});
app.listen(8888);
EDIT: it works when i am in (.../server/
directory) and node server.js
, it is wierd, becouse it should get right path from app.locals.setting.views
variable.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to set handlebars layout directory? - Stack Overflow
You need to point the directories while creating an instance of it. const hbs = exphbs.create({ extname :'hbs', layoutsDir : 'path/to/layout ...
Read more >How to change default view in Windows Folder Explorer
How to change default view in Windows Folder Explorer ; a. · Click on Organize menu and click on click Folder and Search...
Read more >How to set a default Folder View for all folders in Windows 11/10
There are mainly two methods. First, you can right-click after opening a folder and select the Properties option.
Read more >How to Set a Default Folder View for All Folders in Windows ...
How to Set a Default Folder View for All Folders in Windows 11/10In Windows File Explorer, ... Your browser can't play this video....
Read more >How to Fix Set Default Location Button Not Working ... - YouTube
When you click on this default location option, it does nothing on Windows 11. Even if you enable the location and let apps...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@camabeh - I have exactly the same issue. I modified (temporary) the code in the library according to your PR changes and confirm that it solves the problem. Until your PR is merged I choose to set
layoutsDir
andpartialsDir
in engine factory:Thanks Bro for this!!