1- Specify the version of node on package.json
"engines": {
"node": "14.x"
},
npm install
heroku local web
Your app should now be running on http://localhost:5000/.
echo "/node_modules
npm-debug.log
.DS_Store
/*.env" > .gitignore
*/
git add .
git commit -m "Added a Procfile."
heroku login
heroku create
git push heroku main
Prequisite:-
try npm run build to check if build script works or not locally.
server.js is present endpoint.
package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"server": "nodemon server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
...
},
"devDependencies": {
...
}
}
Open Heroku.
Connect to git repo.
Press Deploy Btn.