0

I just finished my project and everything seems OK if I run it on localhost. But after I deploy the project on Heroku, the build process is ok, when I try to access the website, I got an Internal Server Error, I have no idea what the log is going to tell me (I'll paste the log below).

VError: Failed to lookup view "index.js" in directory "/app/.build/templates"

at /app/node_modules/makara/node_modules/engine-munger/index.js:99:33
at iterate (/app/node_modules/makara/node_modules/engine-munger/node_modules/permutron/index.js:91:20)
at iterate (/app/node_modules/makara/node_modules/engine-munger/node_modules/permutron/index.js:91:20)

Anybody knows why? Thanks!

Andrey Moiseev
  • 3,914
  • 7
  • 48
  • 64
Travis
  • 1
  • 1
  • Why it wants to find index.js in the templates folder – Travis Nov 15 '16 at 08:06
  • refer this post [Error: Failed to lookup view in Express](http://stackoverflow.com/questions/10216395/error-failed-to-lookup-view-in-express) – anon Nov 15 '16 at 08:06
  • Hey thanks for reply, the link above might be talking about missing a view. But my app works just fine on my laptop, and I have never met that error before. – Travis Nov 15 '16 at 08:38

1 Answers1

0

Here's one likely thing you can check for:

A Kraken app expects all resources (compiled dust templates, compiled LESS files, etc) to be present in the .build directory.

However, when a resource is not found there, the app's behavior is environment specific, based on the current NODE_ENV environment variable.

If not specified, by default, Kraken apps work in development mode. When a resource is not found in .build, the app will try to generate it on the fly.

This is done as a convenience for developers, and it means you don't have to build the app every time you make a change, as resources will be compiled and loaded on the fly when you run your server. (eg: If you make a change to a template, and reload that page, your change will show up immediately. no need to build)

This is less efficient, so typically you'll want to pre-compile all resources (dust templates, LESS files, etc) before deployment.

Heroku, by default is a PRODUCTION environment (See documentation), and they set NODE_ENV to production.

When deployed in production mode, your app expects all resources to be available in the .build directory. If a resource is not found, it will give up.

Solution Build your app before deployment, by running grunt build (See Documentation) Make sure that the .build directory is deployed to Heroku as well.

Lenny Markus
  • 3,398
  • 2
  • 24
  • 30