I am new to Heroku and believe I am following all of the steps outlined on Heroku's website to deploy via node.js – https://devcenter.heroku.com/articles/getting-started-with-nodejs – but despite indications of success, I only see this in the browser when I go to my newly-generated herokuapp.com site.
Cannot GET /
No errors when executing
git push heroku master
My Procfile is simply
web: node app.js
I dont quite understand dynos yet, but there seems to be one running:
heroku ps === web (1X):
node app.js
web.1: up 2014/07/03 23:55:00 (~ 18m ago)
Then:
heroku open Opening APP-NAME... done
But https://APP-NAME.herokuapp.com/ just displays the Cannot GET / message.
I had my dist directory included in my .gitignore file so I was not committing dist to my repo and not pushing it to Heroku. Therefore, Heroku could not find any content to serve.
I updated my .gitignore, committed, and pushed, and my app shows up just fine on Heroku now.
almost 3 years, but I'm answering for reference.
Just a simple example croped for your package.json
{
"dependencies: {
"bower":"^1.8.0",
"grunt":"^1.0.1",
},
"scripts": {
"start": "node ./www.js",
"build": "grunt dist",
"postinstall": "./node_modules/bower/bin/bower install && npm run build"
}
}
Obvious you're probably done and better nowadays...I'm just referencing it for next consultings.
Make sure you have these 2 things in place:
"scripts": {
"heroku-postbuild": "npm install --prefix client && npm run build --prefix client"
},
if (process.env.NODE_ENV === "production") {
app.use(express.static("build"));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "build", "index.html"));
});
}
Express will serve up production assets like our main.js file, or main.css file
Finally- Express looks if the request is for an asset Express will serve up the index.html file if it doesn't recognize the route
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With