将我的节点js项目部署到主机后出现内部服务器错误 [英] Got a internal server error after I deploy my node js project to the host

查看:134
本文介绍了将我的节点js项目部署到主机后出现内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚完成我的项目,如果我在本地主机上运行它,一切似乎都可以。但是,当我在Heroku上部署项目后,构建过程没问题,当我尝试访问网站时,出现了内部服务器错误,我不知道日志

  VError:无法查找视图index.js在目录/app/.build/templates

在/app/node_modules/makara/node_modules/engine-munger/index.js:99:33
在iterate(/ app / $ node_modules / makara / node_modules / engine-munger / node_modules / permutron / index.js:91:20)迭代时
(/app/node_modules/makara/node_modules/engine-munger/node_modules/permutron/index.js: 91:20)

有人知道为什么吗?感谢!

解决方案

以下是您可以检查的一件可能的事情:

一个Kraken应用程序期望所有资源(编译后的灰尘模板,编译后的LESS文件等)存在于 .build 目录中。然而,当没有找到资源时,应用程序的行为是特定于环境的,基于当前的 NODE_ENV 环境变量。



如果未指定,默认情况下,Kraken应用程序以开发模式运行。
当在 .build 中找不到资源时,应用程序将尝试在运行中生成它。

这是为了方便开发人员完成的,这意味着您不必每次修改应用程序就编译应用程序,因为资源将被编译和加载当你运行你的服务器时。 (例如:如果您对模板进行了更改并重新加载该页面,则您的更改将立即显示出来,无需构建)

这样效率较低,所以通常您需要在部署之前预先编译所有资源(灰尘模板,LESS文件等)。



默认情况下,Heroku是 PRODUCTION environment(请参阅文档),并将 NODE_ENV production



当部署在 production 模式,您的应用程序预计所有资源都可在 .build 目录中使用。如果找不到资源,它就会放弃。



解决方案
在部署之前构建应用程序,方法是运行 grunt build (请参阅文档
Make确保 .build 目录也部署到Heroku。


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!

解决方案

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.

这篇关于将我的节点js项目部署到主机后出现内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆