简体   繁体   English

SyntaxError:在Heroku中以严格模式使用const

[英]SyntaxError: Use of const in strict mode in Heroku

I am following a tutorial from a book, we have just set up a heroku based mongodb database alongside a local database. 我正在看一本书的教程,我们刚刚在本地数据库旁边建立了一个基于heroku的mongodb数据库。 The local app works fine but when I run it on Heroku I get the following error 本地应用程序运行正常,但是在Heroku上运行时,出现以下错误

/app/node_modules/mongoose/lib/index.js:7
const Schema = require('./schema');
^^^^^
SyntaxError: Use of const in strict mode.

I'm guessing that the fact the version of Node on Heroku is different to my localhost but maybe it is not. 我猜测Heroku上的Node版本与我的本地主机不同,但事实并非如此。

when I do node --version on my local I get 当我在本地上执行节点--version时

v8.9.3

when I do it on Heroku I get 当我在Heroku上执行此操作时

v0.10.48

which is a bit confusing. 这有点令人困惑。

How can I fix this so that it runs on Heroku. 如何解决此问题,使其在Heroku上运行。 I have contacted their support but they sent me here as it is an application issue. 我已经联系了他们的支持,但是他们将我发送到了这里,因为这是一个应用程序问题。

Thanks 谢谢

Refer to Heroku documentation . 请参阅Heroku文档 If you want to have a specific version of nodejs, which for example supports const use the engines section of your package.json . 如果要使用特定版本的nodejs(例如支持const使用package.json的engines部分。

Sample from Heroku: 来自Heroku的示例:

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "8.9.4"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM