Deploying App on heroku node command not found - node.js

I have basically modified this app
https://github.com/heroku/node-js-getting-started.git
Now am trying to deploy in Heroku
My Procfile has this line
web:node index.js
And when I run this command locally,there are no probs..
However if I try to open the link in my browser after following all the steps in https://blog.risingstack.com/node-hero-deploy-node-js-heroku-docker/
I get an error
On checking the logs using heroku logs command I am getting 'node command not found'
Anyone knows the prob?
P.S : I tried changing Procfile contents to npm start but that doesnt launch index.js in the browser.

I suspect that you have not set the buildpacks. Buildpacks tells heroku which kind of application is yours.
Use the below command to set the application of type nodejs.
heroku buildpacks:set heroku/nodejs
And make sure that you have a package.json file in the root of the project which is read by heroku to install the project dependencies.

Why don't you try this below in your Procfile.In my case it runs nicely.
web npm install

You just need to add nodejs buildpack on heroku settings app,
after that you will be able to use npm commands.

Related

deploying Node on heroku error after build successful

i have been trying to deploy a node.js app on heroku. the app run successfully on local machine and it build successful with git heroku push master. but when try to open the app on heroku, it shows a blank page and on the console i got the bellow error.
so i my app i uses owlcarousel, and react -carousel. thanks
Try running it locally with NODE_ENV=production node index.js to see if you can reproduce the error like that. Check the .gitignore to see if you are not leaving out some important files. Check the package.json If a module that is included in the package.json is missing from the build or the production app, it may have been removed by Heroku during pruning. And also, in order to create a smaller slug size for apps, the buildpack will prune out the devDependencies from the package.json at the end of the build, so that the slug will only include the dependencies that are listed at runtime. If there is a dependency that is in the devDependencies that is needed after the prune occurs, move the dependency to dependencies, so it is not removed. Look here for more info, troubleshooting Node.js deployment on Heroku.

How to get heroku to detect nodejs buildpack?

I am trying to deploy a web app to heroku but keep getting this error:
`-----> Failed to detect app matching https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz buildpack`
Here is a simplified look my app file structure:
myProject
|__server
|__server.js
|__react_component_1
|__react_componet_2
|__styles</p>
The express server is the server.js inside the server directory and it will the entry way to my app.
It seems like this question has been asked many times before and I've read all the answers, here's what I have tried:
I am deploying from the root folder, myProject, which did not have a package.json file. I've tried npm init to set up a package.json so heroku can detect the app as nodejs. I've also made sure that package.json is being tracked by git. I've made a Procfile: web: cd server && npm run start. I have run the command in the cli to set buildpack: heroku buildpacks:set heroku/nodejs but so far none of it has worked. I've also tried buildpacks:clear after setting everything up to see if heroku can automatically detect buildpacks now that I have a package.json.
Any help is appreciated, thank you.
According to Heroku's relevant documentation on Node.js buildpacks:
The Heroku Node.js buildpack is employed when the application has a package.json file in the root directory.
Based on your Procfile content, web: cd server && npm run start, that looks like you ran npm init inside the server directory, not the root directory.
I think if you move package.json and the node_modules folder one directory down to the root, the buildpack issue will be resolved. Just make sure to change your Procfile to web: npm run start because it would be the same directory now.

How to run a npm script on a deployed Heroku NodeJS app

Under scripts in package.json I have the following.
'refresh': node refresh db
Is there a way to trigger this particular npm script on a NodeJS app deployed on Heroku.
Yes:
$ heroku run npm run refresh
Per the Heroku Node.js Documentation, you can add pre and post install scripts. In addition, you can add scripts that can be triggered by environment variables.
You can also do this using only the browser; Just log in to manage your app in the heroku dashboard (https://dashboard.heroku.com/apps/[app_name]) and there click on the right side of it:
More > Run console
Then you can run any command:
command line in heroku
https://devcenter.heroku.com/changelog-items/1137

Install Twilio on Heroku Parse Server

I've got a working Parse Server running on Heroku, and I'm trying to get my Twilio cloud code working. As soon as I add var twilio = require('twilio')(twilioAccountSid, twilioAuthToken); to my main.js, the app breaks. The migration guide from Parse.com (https://github.com/ParsePlatform/parse-server/wiki/Migrating-an-Existing-Parse-App#3-cloud-code) shows that Twilio should be installed from the "official npm module". How does one do that? Thanks for any help!
I had to modify package.json, adding "twilio": "~2.9.0" as a dependency. I was also able to troubleshoot this better by installing the Heroku toolbelt, and running heroku logs --tail --app your_app_name from the terminal. I originally installed twilio via the Heroku toolbelt, by running heroku run npm install twilio --app your_app_name, but I'm not sure if that was required or not.

Local or Private NPM module when deploying to Heroku

I have a node app that has a local npm module npm link ./local and I'm trying to deploy the app to heroku. Heroku runs npm install when I deploy, but npm link's aren't saved in package.json so my local module is missing.
I'm new to heroku and Procfiles, I'd like to run a script or just run npm link ./local before on the heroku box.
Alternatively I could put the module on github as a private repository and link it from there. But as far as I know Heroku isn't able to download private repo. Can I give Heroku access to my github repository via keys so that it could download it?
I'd love for somekind of solution! Anything!
I think you need yo put modules in node_modules folder and push that to heroku
Procfiles are easy to maintain and heroku will read that
I have sample Procfile like
web: bin/hubot -a campfire
Even heroku also says that best is to include node_modules into repo so you can just include your local packages into that.
See more here Heroku Node Deploy

Resources