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:
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:
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:
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!