I've created a server for my front end project using nodejs on the back end. after testing it successfully on my computer(localhost:3001),I wanted to deploy it on heroku.
to do so, I ran the following codes on gitbash(windows) :
1-git init
2-git add .
3-git commit -m "my 1st commit"
4-heroku create
5-git remote -v
6-heroku rgit:remote -a blah-blah-21222
7-git push heroku master
here's the error I stumbled upon :
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/blah-blah-21222.git'
I even changed the last line of my codes on server.js Which initially was :
app.listen(3001,()=>{
console.log('app is running on port 3001');
})
and switched it to :
app.listen(process.env.PORT||3001,()=>{
console.log(`app is running on port ${process.env.PORT}`);
})
I got the same error as well and I don't feel like if this port change is the main challenge in the first place.
Do you have any idea how I can deploy this nodejs server on heroku ?
You should create a named app with command :
heroku create blah-blah-21222 // blah-blah-21222 is name you want (not duplicate)
When you use:
heroku create
heroku
create random name for you, please sure thas name is blah-blah-21222
Try it and see any error ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.