繁体   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