Node process won't start with bot - node.js

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

Related

Node gets wrong HTML from package.json when executing npm start

I have a package.json file that looks like:
{
"name": "assignment-1",
"version": "1.0.0",
"description": "This is the Git and Node basic learning project",
"main": "aboutus.html",
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://path_to_git/first-assignment.git"
},
"author": "",
"license": "ISC",
"homepage": "https://path_to_git/first-assignment#readme",
"devDependencies": {
"lite-server": "^2.2.2"
},
"bugs": {
"url": "https://path_to_git/first-assignment/issues"
},
but when I execute npm start, instead of aboutus.html, the index.html webpage opens.
Any idea what I am doing wrong and I don't get the aboutus.html loading as I want it to?
I think I've found the solution:
The index.html appears as the default page, in localhost:3000. Then I simply need to write localhost:3000/aboutus.html to get to the page I wanted to go... Seems like it was pretty simple after all!

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

What is the idiomatic way to run a Node.js project

what is the idiomatic way to run a Node.js project that has package.json with '"main": "index.js"' inside? do I run something like "node run" or "npm run" ?
The package.json file:
{
"name": "bandymas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
And index.js file exists. So what is the idiomatic way?
You can add a start script to your package.json:
{
"name": "bandymas",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC"
}
This way, you can start your project by just running npm start.

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

http-server not stopping server when using Ctrl+C

I am using a simple npm module http-server https://www.npmjs.com/package/http-server to server static website.
This is my package json
{
"name": "dashboard-ng-starfleet",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"./node_modules/http-server/bin/http-server -p=8080"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"homepage": "",
"devDependencies": {
"http-server": "^0.10.0"
}
}
Server starts once but once i stop it using Ctrl+C in terminal and again start server, it says Address already in use.
Ideally it should have stopped.
Any help ?
Your start script should be
"start":"./node_modules/http-server/bin/http-server -p 8080"

Resources