Handlebars throws Missing helper when a template calls a name it does not know
Error: Missing helper: "formatDate"Short answer
Handlebars throws Missing helper when a mustache has arguments and its name is neither a registered helper nor a context property. Either the helper was never registered with Handlebars or express-handlebars, or you wrote a property path with a space where a dot belongs. Register the helper or fix the expression.
Fix it fast
1Find out which cause you have
The quoted name in the message is what Handlebars could not resolve. Search your templates for that exact name.
grep -rn "formatDate" views/2Match what you see, then jump to its fix
- 1
Missing helper: "<name>" for a function you meant to call, like formatDateThe helper was never registeredFix - 2
Missing helper: "user" for a template such as {{user name}}A property path was written with a space, so it is read as a helper callFix - 3
Templates come from content authors and may use names that do not existA missing-helper handler is needed for names you cannot know in advanceFix
- 1
What does the error look like?
Error: Missing helper: "formatDate"Error: Missing helper: "name"Error thrown from res.render('home')
Cause 1 of 3
The helper was never registered
1Check
A helper called with parameters must exist at render time. With express-handlebars, helpers come from the global registerHelper, the helpers option on create() or engine(), or the render call.
grep -rn "registerHelper\|helpers:" src/ app.js2Fix
Register it on the instance that renders your views.
import { create } from 'express-handlebars';
const hbs = create({
helpers: {
formatDate(d) { return new Date(d).toLocaleDateString('en-GB'); },
},
});
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');3Verify
Render the page again. The helper output replaces the error.
curl -s http://localhost:3000/ | grep -i "error" || echo okConfirmed by github.com
Cause 2 of 3
A property path was written with a space, so it is read as a helper call
1Check
A helper call is a name followed by space-separated parameters. {{user name}} calls a helper called user with the parameter name, while a property path uses a dot.
grep -rn "{{[a-zA-Z]* [a-zA-Z]*}}" views/2Fix
Use a dot for property access. If a helper and a property share a name, the helper wins, and ./ or this. selects the property.
{{user.name}}
{{this.name}}3Verify
Reload the page and confirm the value renders.
curl -s http://localhost:3000/profileConfirmed by handlebarsjs.com
Cause 3 of 3
A missing-helper handler is needed for names you cannot know in advance
1Check
By default, a mustache with no parameters is ignored, while one with a parameter throws. Handlebars lets you register a helper named helperMissing to decide what happens.
grep -rn "helperMissing" src/2Fix
Register helperMissing that returns an empty string or a safe marker. The name being called is in options.name.
Handlebars.registerHelper('helperMissing', function (...args) {
const options = args[args.length - 1];
console.warn('Unknown helper', options.name);
return '';
});3Verify
Render a template with an unknown helper. It logs a warning and the page still loads.
curl -s http://localhost:3000/ | head -n 20Confirmed by handlebarsjs.com
How do I stop it coming back?
- Keep helpers in one module that is imported before the first render.
- Use strict dotted paths for data and reserve spaces for real helper calls.
- Render each template in a test so a missing name fails in CI, not in production.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
Axios call from a React app comes back 404
404 (Not Found)
Status code 404 means a server answered, but it has nothing at that path.
3 causes, each with a fixBack end
bcrypt.hash throws 'data and salt arguments required'
Error: data and hash arguments required
The bcrypt package throws this when hash gets null or undefined for the password or for the salt.
4 causes, each with a fixBack end
bcryptjs rejects hash() or compare() with Illegal arguments
Error: Illegal arguments: string, undefined
bcryptjs checks the types of its two arguments and, when either is wrong, throws Illegal arguments followed by the typeof of the first and the second.
3 causes, each with a fixBack end
Express warns 'body-parser deprecated undefined extended'
body-parser deprecated undefined extended
The warning appears because urlencoded() was called without the extended option, which body-parser 1.x has warned about since version 1.4.0.
3 causes, each with a fixBack end
Browser blocks a stylesheet or script: MIME type mismatch with nosniff
The Network tab shows the asset URL answered with Content-Type text/html
With X-Content-Type-Options: nosniff the browser accepts a stylesheet only as text/css and a script only as a JavaScript type.
3 causes, each with a fix