The picture above show some error which occurred during the deployment of the Nodejs app with Heroku.com. There can be two common reason for this
- First one is the Port
- Second one is the script associated with ‘Start’
Port
The running port of the Nodejs app may be set for testing of the app. To make port suit with Heroku use the following
app.listen(process.env.PORT || 3000, () => { console.log(`listening to ${process.env.PORT}`); });
Start Script
The second reason of the error can be the start script. Usually you may set the script as follow for development purposes ( with nodemon, which is not required for production).
"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "nodemon index.js" },
Go to your package.json file and replace the start script with node version as follows
"scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node index.js" },
and it will work