I am completely lost with this problem, I'm sure I must now be being blind but I can't fix it. Heroku is returning a partial could not be found error (below) for a partial that does exist.
Note: this all works perfectly on localhost.
Using
File Structure:
| > Server
| > server.js
| > Views
| > layout.hbs
| > Partials
| > pageheader.hbs
server/server.js
let app = express();
hbs.registerPartials(__dirname + '\\..\\views\\partials');
app.set('view engine', 'hbs');
app.get('/', (req, res) => {
res.render('layout.hbs', {
title: 'Home'
}
});
views/layout.hbs
...
<body>
{{> pageheader}}
</body>
...
views/partials/pageheader.hbs
<h1>{{title}}</h1>
and finally...
Heroku Log
/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:266
throw new _exception2['default']('The partial ' + options.name + ' could not be found');
^
Error: The partial pageheader could not be found
at Object.invokePartial (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:266:11)
at Object.invokePartialWrapper [as invokePartial] (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)
at Object.eval [as main] (eval at createFunctionContext (/app/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:12:28)
at main (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32)
at ret (/app/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12)
at ret (/app/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21)
at render_file (/app/node_modules/hbs/lib/hbs.js:49:23)
at render_with_layout (/app/node_modules/hbs/lib/hbs.js:80:5)
at cacheAndCompile (/app/node_modules/hbs/lib/hbs.js:151:5)
at /app/node_modules/hbs/lib/hbs.js:171:7
at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
I appreciate any help / suggestions, I have searched google, read anything I can find that seems to relate. I just don't understand why this works on localhost and not on Heroku.
So... I think I have found the problem as the '..' portion of the path.
I have moved server.js to root and altered file references to match that change... it works fine everywhere now.