ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

Partial could not be found #286

Closed namPS closed 4 years ago

namPS commented 4 years ago

Partial not found error when deployed to Digital Ocean, tried changing file name, adding hbs.registerPartials, but neither works.

> node ./bin/tasks/assemble "production"

events.js:160
      throw er; // Unhandled 'error' event
      ^
Error: The partial global/header could not be found
    at Object.invokePartial (/one-table/node_modules/handlebars/dist/cjs/handlebars/runtime.js:332:11)
    at Object.handlebars.VM.invokePartial (/one-table/node_modules/engine-handlebars/index.js:196:26)
    at Object.invokePartialWrapper [as invokePartial] (/one-table/node_modules/handlebars/dist/cjs/handlebars/runtime.js:84:39)
    at Object.eval (eval at createFunctionContext (/one-table/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:262:23), <anonymous>:10:31)
    at main (/one-table/node_modules/handlebars/dist/cjs/handlebars/runtime.js:208:32)
    at ret (/one-table/node_modules/handlebars/dist/cjs/handlebars/runtime.js:212:12)
    at ret (/one-table/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:519:21)
    at Object.render (/one-table/node_modules/engine-handlebars/index.js:94:14)
    at /one-table/node_modules/engine-cache/index.js:251:14
    at Object.engineRender [as render] (/one-table/node_modules/engine-cache/index.js:287:7)

config.js

var express = require('express');
var bodyParser = require('body-parser');
const methodOverride = require('method-override');
var errorHandler = require('errorhandler');
var path = require('path');
var exphbs = require('express-handlebars');
const helpers = require( 'handlebars-helpers')();

module.exports = function() {
  var app = express();

  app.engine('.hbs', exphbs({
    extname: '.hbs',
    helpers: require(path.join(__dirname, 'src', 'templates', 'helpers', 'render')),
    layoutsDir: path.join(__dirname, 'src','templates', 'layouts'),
    partialsDir: path.join(__dirname, 'src','templates', 'partials'),
    defaultLayout: 'default'
  }));

  app.set('port', 8080);
  app.set('views', path.join(__dirname, 'src','templates','pages'));
  app.set('view engine', 'hbs');
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  app.use(methodOverride());
  app.use(errorHandler());
  app.use(express.static(path.join(__dirname, './build')));

  return app;
}();
UziTech commented 4 years ago

This repo is no longer maintained. New versions of express-handlebars are maintained at https://github.com/express-handlebars/express-handlebars. If you create an issue there we can try to help you.

namPS commented 4 years ago

Thanks - just created the issue in the new version