问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/40604697/got-a-internal-server-error-after-i-deploy-my-node-js-project-to-the-host