heroku无法从默认的node-js-sample创建应用

时间:2019-03-23 08:42:30

标签: node.js heroku

我派生了node-js-sample,并添加了index.htm和一些内容 当我单击按钮“ Doploy to heroku”时,应用无法构建,并出现以下错误:

-----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NODE_ENV=production
   NODE_MODULES_CACHE=true
   NODE_VERBOSE=false

-----> Installing binaries
   engines.node (package.json):  4.0.0
   engines.npm (package.json):   unspecified (use default)

   Resolving node version 4.0.0...
   Downloading and installing node 4.0.0...
   Detected package-lock.json: defaulting npm to version 5.x.x
   Bootstrapping npm 5.x.x (replacing 2.14.2)...
   npm 5.x.x installed
ERROR: npm is known not to run on Node.js v4.0.0
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least 4.7.0 to use this
version of npm. You can find the latest release of Node.js at 
https://nodejs.org/
ERROR: npm is known not to run on Node.js v4.0.0
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least 4.7.0 to use this
version of npm. You can find the latest release of Node.js at 
https://nodejs.org/
ERROR: npm is known not to run on Node.js v4.0.0
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least 4.7.0 to use this
version of npm. You can find the latest release of Node.js at 
https://nodejs.org/
-----> Change to Node.js build process 
   Heroku has begun executing the "build" script defined in package.json
   during Node.js builds.
   Read more: https://devcenter.heroku.com/changelog-items/1573
-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/

   Love,
   Heroku

!     Push rejected, failed to compile Node.js app.
!     Push failed

据我所知,heroku尝试使用错误版本的node.js运行我的代码,但是为什么呢?

2 个答案:

答案 0 :(得分:1)

该存储库四年或更长时间没有更新,仍然依赖于node.js 4并在package.json上列出了相同的版本。这是一个兼容性问题,在部署之前将其更改为6.0.0并尝试使用,您可能很幸运。

答案 1 :(得分:0)

最近遇到了一个非常痛苦的问题,在这里https://devcenter.heroku.com/articles/nodejs-support

找到了解决方案

当前支持的版本为10.x,12.x,13.x和14.x。

您应始终指定与运行时匹配的Node.js版本 您正在开发和测试。

全局更新节点,并在package.json中指定引擎,例如:

"engines": {
"node": "10.20.x"

},

希望这对某人有帮助