【问题标题】:Deploying node.js application to Heroku将 node.js 应用程序部署到 Heroku
【发布时间】:2012-04-16 04:07:40
【问题描述】:

使用dead simple tutorial on Heroku's website 并在我运行git push heroku master 时收到以下错误:

       Using Node.js version: 0.4.7
       Using npm version: 1.0.106
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
       npm ERR! Couldn't read dependencies.
       npm ERR! Failed to parse json
       npm ERR! Unexpected token }
       npm ERR! File: /tmp/build_17bicinzz6vv0/package.json
       npm ERR! JSON.parse Failed to parse package.json data.
       npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
       npm ERR! JSON.parse 
       npm ERR! JSON.parse This is not a bug in npm.
       npm ERR! JSON.parse Tell the package author to fix their package.json file.
       npm ERR! 
       npm ERR! System Linux 2.6.32-343-ec2
       npm ERR! command "/tmp/node-node-c3iD/bin/node" "/tmp/node-npm-E95q/cli.js" "install" "--production"
       npm ERR! cwd /tmp/build_17bicinzz6vv0
       npm ERR! node -v v0.4.7
       npm ERR! npm -v 1.0.106
       npm ERR! file /tmp/build_17bicinzz6vv0/package.json
       npm ERR! code EJSONPARSE
       npm ERR! 
       npm ERR! Additional logging details can be found in:
       npm ERR!     /tmp/build_17bicinzz6vv0/npm-debug.log
       npm not ok
 !     Failed to install --production dependencies with npm
 !     Heroku push rejected, failed to compile Node.js app

我的 package.json 是:

{
  "name": "node-example",
  "version": "0.0.1",
  "dependencies": {
    "express": "2.2.0"
  }
}

我从他们的教程中得到的 JSON 绝对没有问题,因为当我在本地运行它时,它运行良好。为什么会出现此错误?

【问题讨论】:

  • 看起来完全有效并为我验证 - 你确定你已经对文件进行了任何更改并推送到 git,以便将正确的文件推送到 Heroku?
  • 我提交并推送了我的所有更改,但它仍然无法正常工作。我只是从相同的教程重新开始,一切正常。不知道我第一次搞砸了什么,但第二次效果很好。

标签: json node.js heroku


【解决方案1】:

我觉得这会有答案

 npm ERR! Additional logging details can be found in:
       npm ERR!     /tmp/build_17bicinzz6vv0/npm-debug.log

【讨论】:

    【解决方案2】:

    尝试按照 Heroku 教程提供的 package.json 中的全部内容添加...... 我也遇到了同样的错误,通过添加引擎将其删除。

    `{
        "name": "app-name",
        "version": "0.0.1",
        "private": true,
        "dependencies": {
          "express": "~2.5.8",
          "ejs": "~0.7.1",
          "socket.io": "~0.9.6"
      },
      "engines": {
        "node": "0.6.x"
      }
    }`

    【讨论】:

      【解决方案3】:

      尝试更新版本的 Node.js

      【讨论】:

        猜你喜欢
        • 2021-08-29
        • 2012-10-30
        • 2020-11-30
        • 1970-01-01
        • 2017-09-14
        • 2016-04-08
        • 2016-07-24
        • 2021-03-13
        • 2014-07-16
        相关资源
        最近更新 更多