当我在项目中包含 express-handlebar 时,应用程序在 heroku 上崩溃,但在本地工作
App crashed on heroku when i included express-handlebar in the project, but works locally
这是我添加到应用程序中导致它在 Heroku 服务器上崩溃的代码,删除这些代码会使应用程序在 heroku 上正常工作我的应用程序在本地使用这些代码
const exphbs = require('express-handlebars')({extname:"hbs"})
app.engine('hbs', exphbs);
app.set('view engine', 'hbs');
here is the logs below
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/h5Mer.png
spread operator in object literals was introduced in Node.js v8.3.0. Looks like the app is running on an older version of Node.js on Heroku. Since you mention the app works locally, it is clear that the development and production environments are not using the same version of Node.js. You should specify the version of Node.js (should be v10+ since express-handlebars v5.0.0 放弃了对节点 10 以下版本的支持)该应用程序在 package.json
中使用 Heroku 在部署中使用。
来自 Heroku 的 Node.js 部署 docs:
It’s a good idea to keep your development environment and production environment as similar as possible. Therefore, make sure that your local version of Node.js matches the version you told Heroku to use in the package.json
file. To check which version you’re running locally, at the command line, type node --version
.
这是我添加到应用程序中导致它在 Heroku 服务器上崩溃的代码,删除这些代码会使应用程序在 heroku 上正常工作我的应用程序在本地使用这些代码
const exphbs = require('express-handlebars')({extname:"hbs"})
app.engine('hbs', exphbs);
app.set('view engine', 'hbs');
here is the logs below
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/h5Mer.png
spread operator in object literals was introduced in Node.js v8.3.0. Looks like the app is running on an older version of Node.js on Heroku. Since you mention the app works locally, it is clear that the development and production environments are not using the same version of Node.js. You should specify the version of Node.js (should be v10+ since express-handlebars v5.0.0 放弃了对节点 10 以下版本的支持)该应用程序在 package.json
中使用 Heroku 在部署中使用。
来自 Heroku 的 Node.js 部署 docs:
It’s a good idea to keep your development environment and production environment as similar as possible. Therefore, make sure that your local version of Node.js matches the version you told Heroku to use in the
package.json
file. To check which version you’re running locally, at the command line, typenode --version
.