簡體   English   中英

Heroku部署應用程序時出錯:無法解析package.json

[英]Heroku error deploying app: unable to parse package.json

我對Heroku真的很陌生,並且一直在嘗試使用node.js部署Hello World應用程序。

問題是我有這個

error: failed to push some refs to 'https://git.heroku.com/sebasaenz.git'

但我真的不知道如何解決這個問題。 通過前面的錯誤消息,它似乎與package.json文件有關,但是我試圖在文檔中查找可能是問題所在,而我真的不知道可能是什么。

這是輸入git push heroku master之后的錯誤消息

Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 920 bytes | 0 bytes/s, done.
Total 6 (delta 0), 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 14, column 3
remote:  !     Unable to parse package.json
remote: 
remote: 
remote: -----> Build failed
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 sebasaenz.
remote: 
To https://git.heroku.com/sebasaenz.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/sebasaenz.git'

我的package.json文件如下:

{
  "name": "hello-world",
  "version": "1.0",
  "description": "Node demo",
  "engines": {
    "node": "5.9.1"
  },
  "main": "index.js",
    "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "ejs": "2.4.1" 
  }, //this is line 14 
  "repository": {
    "type": "git",
    "url": "https://git.heroku.com/sebasaenz.git"
  },
  "keywords": [
    "node",
    "heroku"
  ],
  "license": "MIT"
}

我已經在尋找具有類似特征的帖子,但沒有找到任何可以幫助我的東西。

您提供的JSON中唯一無效的位是依賴項中"ejs": "2.4.1"和關鍵字數組中"heroku"后的逗號。

我有同樣的問題。 請注意heroku中的這兩行:

remote: parse error: Expected another key-value pair at line 14, column 3
remote:  !     Unable to parse package.json

您的package.json文件有問題。 就我而言,我缺少括號以最后關閉文件。 請參閱以下示例:

{
  "name": "tempdeployment",

  "version": "1.0.0",
  "description": "This version of __ is for temporary deployment.",
  "main": "app.js",
  "scripts": {
    "test": "test.js",
    "start": "node app.js"
  },
  "author": "____",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.5.7",
    "express": "^4.16.2",
    "request": "^2.83.0"
  },
  "engines": {
    "node":"^8.9.4"
  }

請注意,此JSON文件缺少右括號。 添加括號后,部署就沒有問題了。 在您的情況下,您似乎對第14行的鍵值對之一有問題。解決此問題,應用程序應該可以正常部署。

這是我的package.json文件的更正版本:

{
  "name": "tempdeployment",

  "version": "1.0.0",
  "description": "This version of __ is for temporary deployment.",
  "main": "app.js",
  "scripts": {
    "test": "test.js",
    "start": "node app.js"
  },
  "author": "____",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.5.7",
    "express": "^4.16.2",
    "request": "^2.83.0"
  },
  "engines": {
    "node":"^8.9.4"
  }
}
mvn clean install

然后推送到heroku大師。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM