Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Handlebars Fails Lookup Only When Running As Service

When running via npm in my project's root directory I have no problems, both local and on the server's machine, but when running as a service handlebars fails to find my view files and outputs this error to my log:

server listening...
Connected
Error: Failed to lookup view "home" in views directory "/views"
    at EventEmitter.render (/var/www/dopWeb/node_modules/express/lib/application.js:580:17)
    at ServerResponse.render (/var/www/dopWeb/node_modules/express/lib/response.js:966:7)
    at /var/www/dopWeb/index.js:45:13
    at Layer.handle [as handle_request] (/var/www/dopWeb/node_modules/express/lib/router/layer.js:95:5)
    at next (/var/www/dopWeb/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/var/www/dopWeb/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/var/www/dopWeb/node_modules/express/lib/router/layer.js:95:5)
    at /var/www/dopWeb/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/var/www/dopWeb/node_modules/express/lib/router/index.js:335:12)
    at next (/var/www/dopWeb/node_modules/express/lib/router/index.js:275:10)

I have a pretty standard config file:

description "dop webserver"
author      "Mike Pawlak"

start on started mountall
stop on shutdown

# automatically respawn

respawn
respawn limit 99 5

script

    export HOME="/root"
    exec /usr//bin/nodejs /var/www/dopWeb/bin/www >> /var/log/node.log 2>&1

end script

and directory structure -

  • project root
    • public
    • nodemodules
    • routes
    • bin
      • www
    • views
      • layouts
        • main
      • home
    • index.js

Index.js code:

...

//rendering engine setup
var handlebars = require('express-handlebars')
  .create({defaultLayout: 'main'});
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');

...

app.get('/', function(req, res) {
        res.render("/home");
})

...
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I never did figure it out, but instead went with this tutorial and set up my service with pm2.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!