【问题标题】:I cannot deploy node.js to Heroku due to a mysterious error由于神秘错误,我无法将 node.js 部署到 Heroku
【发布时间】:2018-01-11 13:09:18
【问题描述】:
C:\Users\Archie Jugdersuren\summaproject_trial3 - Copy 6 - heroku2>git push 
heroku master
Counting objects: 3247, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3049/3049), done.
Writing objects: 100% (3247/3247), 3.88 MiB | 496.00 KiB/s, done.
Total 3247 (delta 811), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote: parse error: Expected another key-value pair at line 20, column 3
remote:  !     Unable to parse package.json
remote:
remote:
remote: -----> Build failed
remote: parse error: Expected another key-value pair at line 20, column 3
remote: parse error: Expected another key-value pair at line 20, column 3
remote:
remote:        We're sorry this build is failing! You can troubleshoot 
common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-
deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to summ2.
remote:
To https://git.heroku.com/summ2.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/summ2.git'

我什么都试过了。这是第 20 行第 3 列的奇怪部分,没有任何问题!!!我什至摆脱了原来的行,看看错误是否仍然存在并且确实存在。此外,我删除了整个 package.json 文件,即使 package.json 为空,它仍然指向第 20 行第 3 列。我已经卸载并重新安装了 Heroku,但没有运气......我已经检查了我的依赖项

这里是 package.json:

{
  "name": "hello world",
  "version": "0.0.0",
  "engines": {
    "node": "6.11.0"
  },
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "1.17.2",
    "cheerio": "1.0.0-rc.2",
    "cookie-parser": "1.4.3",
    "debug": "2.6.3",
    "ejs": "2.5.6",
    "express": "4.15.2",
    "google": "2.1.0",
    "jquery": "3.2.1",
    "morgan": "1.8.1",
    "request": "2.81.0",
    "serve-favicon": "~2.4.2"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/Mongols/Deploy-Node-To-Heroku.git"
  },
  "keywords": [
    "node",
    "heroku",
    "express"
  ],
  "license": "MIT"
}

【问题讨论】:

  • 也许某处还有第二个 package.json?听起来,因为你有一个空文件同样的错误。
  • 我看到这里是截图:imgur.com/a/3JsYz
  • 我认为没有第二个 package.json

标签: javascript html json node.js heroku


【解决方案1】:

在推送到 heroku 之前,您是否重新提交了更改?关于这个问题的大多数答案都是由于某个地方缺少逗号或多余的逗号,我建议将您的代码通过 json 解析器并检查以确保您拥有所有有效的 json。

【讨论】:

  • 在推送到 heroku 之前如何重新提交我的更改?
  • 如果您将远程设置为 heroku,则使用常规 git 工作流程 git add -A git commit -m "your message here" git push heroku master
  • 它们应该是单独的行。我假设你实际上已经在 git 上设置了这个。
  • 我已重新提交,但与第 20 行第 3 列相同的错误仍然存​​在
猜你喜欢
  • 1970-01-01
  • 2020-09-27
  • 2013-10-23
  • 2019-07-21
  • 2021-08-29
  • 2020-07-20
  • 2016-01-05
  • 2017-01-21
  • 1970-01-01
相关资源
最近更新 更多