Monday, 1 May 2017

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


via MPawlak

No comments:

Post a Comment