heroku error: Expected another key-value pair - node.js

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?

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"
}
}

Related

IBM Cloud with Cloud Foundry: Error pushing nodejs app (Error staging application: App staging failed in the buildpack compile phase)

I am making an app with Node.js and trying to upload it to Cloud Foundry on IBM Cloud. It runs well locally but when I try tu push it shows this:
I share you my package.json because I think that there is the problem and my files structure. Thank you!
{
"name": "pruebanode",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"#cloudant/cloudant": "^4.3.1",
"node-cron": "^3.0.0",
"node-fetch": "^2.6.1",
"trello-kb": "^1.5.0"
}
}

Why do I keep getting error trying to run npm scripts?

I am just getting to learn node and webpack. I was following a tutorial, but I keep running into an error. Details of the error and my setup is given below:
error details
log file
My setup
package.json content
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"path": "^0.12.7"
}
}

Node process won't start with bot

I am trying to deploy a bot to run on Heroku servers. It fails to compile the app when I try to commit. Here is my package.json
{
"name": "Bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node bot.js"
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.0.2",
"dotenv": "^8.2.0"
}
}
bot.js is the correct name for the bot configuration file. It works fine when I take out start: node bot.js but the bot doesn't come online of course.
Try Changing main to bot.js.
https://devcenter.heroku.com/articles/deploying-nodejs

Parse error: Expected another key-value pair

I'm trying to host a bot for Discord in Heroku, but when doing git push heroku master it gives me this error:
Node.js app detected
remote: parse error: Expected another key-value pair at line 41, column 1
remote: ! Unable to parse package.json
remote:
remote:
remote: -----> Build failed
remote: parse error: Expected another key-value pair at line 41, column 1
remote: parse error: Expected another key-value pair at line 41, column 1
remote: parse error: Expected another key-value pair at line 41, column 1
This is the content of the package.json file
{
"name": "sebas",
"version": "0.0.5",
"description": "un bot cualquiera",
"main": "index.js",
"engines": {
"node": "8.x",
"npm": "*"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/synicalsyntax/discord.js-heroku.git"
},
"keywords": [
"heroku",
"discord.js"
],
"author": "miguerubsk",
"license": "ISC",
"homepage": "https://github.com/synicalsyntax/discord.js-heroku#readme",
"dependencies": {
"bufferutil": "^3.0.3",
"discord.io": "^2.5.3",
"discord.js": "^11.3.2",
"ffmpeg": "0.0.4",
"ffmpeg-binaries": "^3.2.2",
"node-gyp": "^3.6.2",
"opusscript": "0.0.6",
"uws": "^9.14.0",
"winser": "^1.0.3",
"ytdl-core": "^0.20.2"
},
"devDependencies": {},
"bugs": {
"url": "https://github.com/synicalsyntax/discord.js-heroku/issues"
},
}
You simply needed to remove the comma at the end, as Chris said. This should be the code:
{
"name": "sebas",
"version": "0.0.5",
"description": "un bot cualquiera",
"main": "index.js",
"engines": {
"node": "8.x",
"npm": "*"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/synicalsyntax/discord.js-heroku.git"
},
"keywords": [
"heroku",
"discord.js"
],
"author": "miguerubsk",
"license": "ISC",
"homepage": "https://github.com/synicalsyntax/discord.js-heroku#readme",
"dependencies": {
"bufferutil": "^3.0.3",
"discord.io": "^2.5.3",
"discord.js": "^11.3.2",
"ffmpeg": "0.0.4",
"ffmpeg-binaries": "^3.2.2",
"node-gyp": "^3.6.2",
"opusscript": "0.0.6",
"uws": "^9.14.0",
"winser": "^1.0.3",
"ytdl-core": "^0.20.2"
},
"devDependencies": {},
"bugs": {
"url": "https://github.com/synicalsyntax/discord.js-heroku/issues"
}
}

Update Packages.json automatically with the pre-installed moduels in NODEJS

In my local machine, I worked on a node.js app, I had installed many packages before initializing the package.json.
When I initialized the Package.json using:
npm init
I got the package.json but it does not contain all the dependencies that exist in the node_modules,
Which caused me a problem of missing packages when I moved to the production server (I run npm install)
Is there a way to automatically include all of them in the dependencies part.
Here is the JSON file I have:
{
"name": "xxxx",
"version": "1.0.0",
"description": "xxxxxxx",
"main": "server.js",
"dependencies": {
"date-utils": "^1.2.21",
"mssql": "^4.0.4",
"mysql": "^2.11.1",
"seriate": "^0.9.0",
"websocket": "^1.0.23",
"winston": "^2.2.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://gitlab.com/odot-web/hefner-socket.git"
},
"keywords": [
"nodejs",
"hefner",
"socket"
],
"author": "xxxx",
"license": "ISC",
"bugs": {
"url": "https://gitlab.com/odot-web/hefner-socket/issues"
},
"homepage": "https://gitlab.com/odot-web/hefner-socket#README"
}

Resources