heroku error: Expected another key-value pair

你离开我真会死。 提交于 2020-01-03 08:52:57

问题


I am trying to deploy a nodejs app to heroku for the first time, following heroku's instructions here

When I run git push heroku master, it starts compiling the app, but when it reaches 100% and I get this

parse error: Expected another key-value pair at line 18, column 1

 !     Push rejected, failed to compile Node.js app

To git@heroku.com:agile-sands-7020.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:agile-sands-7020.git'

I have created new keys with ssh-keygen -t rsa and added them to heroku with heroku keys:add but I still get this error. Can someone help me please?


回答1:


Ah, I figured it out, this mysterious error has to do with the package.json file. Basically I botched the "engines" field by declaring it in a seperate json object

{
  "name": "elegant-insults",
  "version": "0.0.0",
  "description": "Insult eachother in the most elegant of ways",
  "main": "server.js",
  "dependencies": {
    "socket.io": "~0.9.16",
    "xml2js": "~0.4.1",
    "express": "~3.4.8"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "author": "roman-sharf",
  "license": "ISC",
  "repository": {
    "type": "git",
    "url": "git@heroku.com:elegant-insults.git"
  }
},
{
"engines": {
    "node": "0.10.x"
  }
}

instead it should be like this:

{
  "name": "elegant-insults",
  "version": "0.0.0",
  "description": "Insult eachother in the most elegant of ways",
  "main": "server.js",
  "dependencies": {
    "socket.io": "~0.9.16",
    "xml2js": "~0.4.1",
    "express": "~3.4.8"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "author": "roman-sharf",
  "license": "ISC",
  "engines": {
    "node": "0.10.x"
  },
  "repository": {
    "type": "git",
    "url": "git@heroku.com:elegant-insults.git"
  }
}


来源:https://stackoverflow.com/questions/21819810/heroku-error-expected-another-key-value-pair

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!