Run heroku-cli command in heroku-based application - node.js

I'm trying to delete heroku application from another heroku web-appication
There is a bash-script: heroku apps:destroy ${APP_NAME} --confirm ${APP_NAME}
Locally it works fine because I have installed heroku-toolbelt; but on heroku-server I get an error: 'heroku: not found'
Is it possible to work with heroku-cli from heroku-based apps?

You can use the heroku toolbelt buildpack, which provides the toolbelt alongside your application:
https://github.com/gregburek/heroku-buildpack-toolbelt
You can also use the heroku API directly from your app:
https://devcenter.heroku.com/categories/platform-api

Related

error code=H14 desc="No web processes running" after trying to deploy Puppeteer app Heroku

I am trying to deploy a simple app to Heroku that performs Web Scraping using Puppeteer.
Since there's a problem using Puppeteer in Heroku, I needed to define a buildpack to support Puppeteer, following these articles:
Puppeteer unable to run on heroku
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-heroku
https://github.com/jontewks/puppeteer-heroku-buildpack
Following these steps gave me the following error:
code=H14 desc="No web processes running"
after a bit of searching online, I found the following articles:
H14 error in heroku - "no web processes running"
saying that I have no web dynos running, and I have tried to set some up using the suggested command:
heroku ps:scale web=1
But that just gave me this error:
Scaling dynos... ! ▸ Couldn't find that process type (web).
I am running a Node.js app, using Yarn as the package manager.
What should I do?
I'll describe the process I've been through to solve this problem, which required a good amount of time.
First, I made sure that the problem is not caused by using Yarn instead of npm, according to Heroku documentation, if the root folder of your app contains yarn.lock file, then it automatically should use Yarn to build the app. But then they also say that you need to add to your package.json file a description of the version of Yarn your using, so I did:
"engines": {
"yarn": "1.x"
},
That was to make sure the problem is not yarn. which it wasn't.
Next, I have tried to understand exactly what the problem is with the web dynos, after a lot of searching I came across this:
https://help.heroku.com/W23OAFGK/why-am-i-seeing-couldn-t-find-that-process-type-when-trying-to-scale-dynos
This article also suggested using the heroku buildpacks:clear as the previous suggestion in the StackOverflow issue, but it said one more thing, super important:
Remove the existing Buildpacks...and add them again in the right order
What order? well... apparently that when I followed the previous StackOverflow issue, I have removed all the Buildpacks that came with the Heroku setup, including a very important one the heroku/nodejs build pack.
So I figured I have to re-add it to my Buildpack list. I also figured that if that is the default Buildpack that should be number one in the list, and the Buildpack for puppeteer should come after that (can be done by using the --index flag).
Finally, I solved the problems by running the following commands:
$ heroku buildpacks:clear
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add --index=2 jontewks/puppeteer
$ git commit --allow-empty -m "Adjust buildpacks on Heroku"
$ git push heroku master
Running $ heroku buildpacks to confirm, returned the following:
=== workday-jobs Buildpack URLs
1. heroku/nodejs
2. jontewks/puppeteer
Now I know I have the necessary Buildpacks, in the right order, and it works!

How do I deploy NodeJS server that's for a React Native App to Heroku?

I have an app using React Native as its frontend, and NodeJS as backend, and it also has a cloud MySQL instance. I want to deploy the app to the public and show it to someone as demo using Heroku or maybe other hosting services.
I want to publish my React Native App with Expo, but am not sure how/ where to host my nodeJS server so that the mobile app can access it.
Steps for deploying React native/expo app to heroku:
1: set heroku buildpack as static: >heroku buildpacks:set heroku-community/static
2: Add static.json for static buildtype: { "root": "web-build/", "routes": { "/**": "index.html" } } More settings here: https://github.com/heroku/heroku-buildpack-static#configuration
3: npm run build (package.json: "build": "expo build:web") --> Creates web-build folder
git add .
git commit
git push heroku master
heroku open
You can follow Heroku official document to deploy your NodeJS server.
https://devcenter.heroku.com/articles/deploying-nodejs
Then you can access the domain provided by Heroku just exactly like on your localhost.

Error pushing nodejs(express) app to heroku

I'm trying to push my nodejs(express) app to heroku using heroku push master.
I keep getting the following error:
App not compatible with buildpack:
https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz
when I participated at Node Knockout last year, I ran into the same problem.
Turned out I forgot to add a Procfile.
Do you have one? If so, could you share its content?

'heroku local' cannot find module 'load-foreman-procfile'

I'm trying to run Heroku applications locally via 'heroku local,' but a missing module error is occurring in the Heroku CLI. Is this a Heroku bug that just needs to be reported or is there something wrong with how things have been setup on my machine (mac)? Any suggestions are appreciated.
In order to ensure my application isn't the problem, I've been debugging this issue with the node application Heroku provides in its getting started guides. Meaning, it already has a Procfile that can be run using default settings.
Things I've tried:
Re-install node modules for both application and CLI
Re-install the Heroku CLI
Here's the error:
node-js-getting-started [master] :> heroku local
Error: Cannot find module '../../load-foreman-procfile'
at Object.<anonymous> (/usr/local/Cellar/heroku/7.26.1/libexec/node_modules/#heroku-cli/plugin-local/lib/commands/local/index.js:5:18)
The file for the route above requires a 'load-foreman-procfile' like so:
const Procfile = require('../../load-foreman-procfile');
That require path doesn't lead to a to file by that name. In fact, this is the only reference to 'load-foreman-procfile' I can find in '/usr/local/Cellar/heroku/7.26.1'.
Rather than the error code above, I would expect heroku local to yield a running local server started via my Procfile.
I got the same error running heroku-cli v7.26.0. I switched to their edge channel (currently v7.26.2) and heroku local worked for me after that.
like #sophon mentioned - updating from v7.26.0 to v7.26.2 solved this for me. heroku update on mac did the trick.

Running blockchain-wallet-service on a Heroku worker

I'm trying to deploy my Django app on Heroku, that makes use of the Blockchain.info API V2 (https://github.com/blockchain/service-my-wallet-v3) and thus needs to run blockchain-wallet-service in the background, which in turn needs Node.js and npm installed.
On localhost, I have used this API successfully by running the service on my own machine, but I'm having trouble deploying to Heroku. Firstly, I assume I will need to run the service on a separate dyno, and that I will need node and npm installed on my instance.
Can someone tell me how to achieve this? I'm new to more advanced features of Heroku, I've tried to use the nodejs buildpack but I doubt this is the correct way. There is also this: https://elements.heroku.com/buttons/kmhouk/service-my-wallet-v3 which I've deployed as a separate app but I've failed to merge it in some way to my Django app.
Any help is much appreciated!
I had this exact same issue, bro, and i finally got some light in the end of the tunnel.
I've cloned the https://github.com/blockchain/service-my-wallet-v3 repository and deployed it to heroku and made some changes on "package.json" file. The problem is that (in heroku) you need to declare the dependencies on package file. I've added these lines:
"dependencies": {
"blockchain-wallet-service": "~0.22.4",
}
and a script to test in the deploy:
"scripts": {
"postinstall": "blockchain-wallet-service -V"
}
Also, by cloning this repository, i needed to add this line too:
"license" : "(ISC OR GPL-3.0)",
hope it works for you

Resources