Heroku deployment fails with "missing script: start" - node.js

I am trying to upload my local MEAN stack based web application to my Heroku server. I have updated my code in Bitbucket and have successfully done the Heroku deployment part. But, the web app is still not live. When I hit the page, I am getting something like this:
I then checked the logs by firing 'heroku logs' but I am unable to understand what the logs are trying to ask for. I am sharing the logs below:
As I understand it, the application was unable to find "start" but I have later exclusively added "start" : "node app.js" but I still don't see any difference in the heroku logs or in the heroku link.
Can anyone help with what am I doing wrong here?
here's my package.json file
{
"start": "node app.js",
"name": "PerosnalPro",
"version": "1.0.0",
"description": "Personal website using dynamic routing and responsive design.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mikey",
"license": "ISC",
"dependencies": {
"dotenv": "^1.2.0",
"ejs": "^2.3.4",
"express": "^4.13.3",
"morgan": "^1.6.1",
"serve-favicon": "^2.3.0",
"slick-carousel": "^1.5.9"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://user#bitbucket.org/username/projectname"
},
"homepage": "https://bitbucket.org/username/projectname"
}

"scripts": {
"start" : "node app.js",
"test": "echo \"Error: no test specified \" && exit 1"
}
Add your start tag in scripts. :)

Related

nodemon not working, Usage: nodemon [nodemon options] [script.js] [args] See "nodemon --help" for more [duplicate]

This question already has answers here:
nodemon not working properly
(19 answers)
Closed 7 months ago.
{
"name": "nodeserver",
"version": "1.0.0",
"description": "This is a node Server for LetsChat Application",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "neetu",
"license": "ISC",
"dependencies": {
"nodemon": "^2.0.4",
"socket.io": "^2.3.0"
}
}
First try to Install Nodemon as Global
npm install -g nodemon
As per your Package.json details, Run
nodemon index.js
If still you face issue, Try to add some details like Error Message you get running nodemon.

Write a custom plugin for a bundler like parcel in a web app

I have my own nodejs web application which is using Parcel 2 to bundle the resources.
{
"name": "acme-web-app",
"version": "0.0.1",
"description": "",
"keywords": [],
"license": "",
"author": "",
"scripts": {
"build": "parcel build index.html",
"dev": "parcel index.html --open",
"start": "npm run build && npm run dev",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"#parcel/packager-raw-url": "^2.6.0",
"#parcel/transformer-sass": "^2.6.0",
"#parcel/transformer-webmanifest": "^2.6.0",
"parcel": "^2.6.0",
"sass": "^1.52.2"
}
}
All works fine - the js bundles end up in a dist folder.
I am contemplating whether it is possible to write a parcel plug-in within this project is executed when the build script is run.
Is it possible - or does every reference need to go through npm channels via devDependencies?
I haven't figured a starting point for this - and have not been able to find what I am looking for on google so hopefully, the question makes sense.
NOTE: I have only really built web applications with nodejs.

nodemon: not found on heroku

My app runs locally with no issues by its failing on Heroku
package.json
{
"name": "app name",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "nodemon app.js"
},
"engines": {
"node": "14.17.0"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"mongoose": "^5.12.9"
}
}
Procfile
web:node app.js
its returning the below error
sh: 1: nodemon: not found
Any help on how to make this work?
The nodemon is installed globally on your machine that's why you are able to run it on your machine. When you are pushing it on Heroku it is showing the error because there is nothing like nodemon.
Also, Heroku doesn't need nodemon so just replace your start script:
node app.js
and change your Procfile to this:
web: npm start
Even I had the same issue.
You just have to remove nodemon from start script
It has to be iin this way;
"scripts": { "start": "src/index.js", "dev": "env-cmd -f ./config/dev.env nodemon src/index.js" }

Discord bot sends response twice

I'm coding a discord.js bot, and whenever I send a command, it gives a response twice. I've concluded it's because I have too many instances running. I try to delete the instances, but it doesn't delete. Sometimes it says "Some instances could not be deleted", and sometimes it doesn't delete at all.
And through Terminal
SERVICE VERSION ID VM_STATUS DEBUG_MODE
default 20191208t223728 aef-default-20191208t223728-0l57 RUNNING
default 20191208t223728 aef-default-20191208t223728-jb53 RUNNING
default 20191208t223728 aef-default-20191208t223728-wpgm RUNNING
This is what the messages look like. There should only be one message, not three.
Here is what my package.json looks like:
"name": "discord-bot",
"version": "1.0.0",
"description": "Custom bot for Chinese Discord server.",
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js",
"build": "next build"
},
"keywords": [],
"author": "Jacob Villorente",
"license": "ISC",
"dependencies": {
"discord.js": "^11.4.2",
"discord.js-commando": "^0.10.0",
"dotenv": "^7.0.0",
"express": "^4.17.1",
"node-fetch": "^2.6.0",
"ytdl-core": "^1.0.3"
},
"devDependencies": {
"nodemon": "^1.18.11"
}
}
Any help would be greatly appreciated. Thank you
There are two ways to resolve your problem.
The first one, and the better, is to use grep to get all your node processes who are running on your machine:
ps -ef | grep node
Then, you will be able to kill them with kill command.
The second way is to change your discord bot token. All the instances will be errored so you're sure there's no instance launched anymore.

How can I deploy a react app with a node backend on GitHub Pages?

I just started learning about concurrently npm to React.
I want to know how to deploy React project on Github page with concurrently npm.
Normally on local machine we would run the app with server side package.json file
"dev": "concurrently "npm run server" "npm run client""
In Terminal> npm run dev
I tried with gh-pages npm to deploy react app on Github page but with concurrently npm,
I have no idea how to do it since there are two package.json.
Also, I don't know much about NODE environment and npm run build.
Server side package.json:
{
"name": "contact-keeper",
"version": "1.0.0",
"description": "Contact manager app",
"main": "server.js",
"homepage": "https://myprofile.github.io/Contact-Keeper-with-React",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "node server.js",
"server": "nodemon server.js",
"client": "npm start --prefix client",
"clientinstall": "npm install --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"config": "^3.1.0",
"dotenv": "^8.0.0",
"express": "^4.17.1",
"express-validator": "^6.1.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.6.4"
},
"devDependencies": {
"concurrently": "^4.1.1",
"gh-pages": "^2.1.1",
"nodemon": "^1.19.1"
}
}
Client side server package.json:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
"react-transition-group": "^4.2.1",
"uuid": "^3.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
}
Is there any document or basic knowledge about setting environment that I need to learn more to understand this topic?
Github is not (quite) a service for serving your working application to other users. Github is a repository for storing your code, updating it, and managing versions.
I think that to deploy your app "concurrently" to github means there is a way of updating Github with the new version code, at the same time as you deploy it online to a service, such as Heroku.
You should research and understand what Git (as opposed to github) is, as its essential for development. Get skilled at managing your app code with git first, before trying to deploy to a service like Heroku, AWS etc....
EDIT
As pointed out by Asaf Aviv, you can serve front-end apps from Github, with github pages, but you still need to be able to push your local code up to github for this to work.

Resources