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