I had a Loopback REST API deployed to Heroku about a year ago. There was no issue before, in fact, I have successfully deployed several versions of the app. Just recently, I was making some revisions to the API and when I tried pushing changes to Heroku, I got several errors in the log and yes the deployment failed.
I checked the guide about StrongLoop buildpacks again to check if they have updated their documentation. Unfortunately, there’s none. I also just found out that the team working on StrongLoop had stopped the support since its acquisition by IBM.
Supported Buildpacks
Heroku currently has 12 officially supported buildpacks.
Buildpacks are responsible for transforming deployed code into a slug, which can then be executed on a dyno. Buildpacks are composed of a set of scripts, and depending on the programming language, the scripts will retrieve dependencies, output generated assets or compiled code, and more. This output is assembled into a slug by the slug compiler.
Some developers have also pointed out that they have sent an email to the support yet still have no response.
Since the issue is not on Heroku itself, there will be changes needed in the configuration.
First, instead of using the Strongloop buildpack you should now use the buildpack for nodejs which can be done by running the following command.
$ heroku buildpacks:set heroku/nodejs
Second, change the content of the Procfile for the process to run from
web: slc run
to
web: node server/server.js
Node.js Runtime
Another thing to take into consideration is the version of the Node.js runtime engine. You need to make sure that the node.js versions in your package.json match the node.js version installed in your local machine.
{ "name": "myapp", "description": "a really cool app", "version": "1.0.0", "engines": { "node": "12.13.0" } }
Verify that you have the same versions of node.js by running the following in your console. It is best to have the latest version of node.js or not later than ^v8.
$ node --version v12.13.0
Other Dependency Issue
While the issues have been slowly fixed by doing the previous solutions. There was still another dependency issue while I was still trying to push my codes to Heroku. Some of the lines read below.
Installing node modules (package.json + package-lock) npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/har-validator/-/har-validator-5.1.2.tgz npm ERR! 404 npm ERR! 404 '[email protected]' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 It was specified as a dependency of 'build_3c796b9746a08af9a5e4cfcdf63a4a5c'
Now, it says ‘[email protected]’ is not in the npm registry.
I tried looking for the version 5.1.2 and indeed found nothing. Then I asked myself. What! Why now?
I checked the git repository for possible issues and a user said.
There is a version mismatch for this package and the npm/yarn repos. The current version is 5.1.2 and it is published under 5.1.3.
So this was the whole thing that fixed everything for me with the REST API finally deployed to Heroku.