Closed Arrow7000 closed 6 years ago
My Procfile in root looks like this:
web: node server/bin/www
And my Procfile in my server/
subfolder I tried both web: node bin/www
and web: node server/bin/www
. Neither worked. Both had the same error in the logs.
Silly me :roll_eyes: I must've had the web process dyno turned off, which explains why no web processes were running.
However the app still doesn't run. When I have a Procfile in root I get the error bash: node: command not found
. When I remove the Procfile from root and only leave the Procfile in server/
, it again doesn't seem to find any web processes.
Where am I supposed to put my Procfiles? And if in my project root, how do I fix the node: command not found error?
Hi @Arrow7000, when you compile your app for deploying, you should be copying the Procfile to the root of the app that you're deploying. If you're deploying from server
then your Procfile should exist at server/Procfile
so that when you deploy, the Procfile
ends up in the root directory.
For starting a node app, it's typical that you have an npm
script, then your Procfile will be something like:
web: npm start
let me know if that works for you or not!
Thanks for replying!
I tried that but now it just says
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
I think it's looking in the root folder for a Procfile, which is why it's not finding the Procfile in server/
. So just to recap:
.buildpacks:
server=https://github.com/heroku/heroku-buildpack-nodejs.git
server/Procfile:
web: npm start
oops, I totally was thinking of a different build system, my bad!
Okay, so to clarify, you should have one Procfile at the root directory that handles running all apps (each in a subdirectory).
Here, you're declaring that server
uses node
and your Procfile should be set up to run the app from that directory as well. If you have a package.json
in the server
directory with a script called start
, then you would have this in your Procfile:
web: cd server && npm start
Can you provide the contents of the build log? Specifically I'm looking for lines that say:
=====> Downloading Buildpack:
=====> Detected Framework:
It's definitely downloading the right buildpack, it did that from the start:
remote: -----> Multipack app detected
remote: =====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git, branch: , to tmp dir /tmp/buildpackpjoQ5, against source's subdir: server
I tried putting the Procfile in the root and making it say web: cd server && npm start
but that still didn't work. It still can't seem to find node/npm commands:
2017-03-30T08:47:56.665968+00:00 heroku[web.1]: Starting process with command `cd server && npm start`
2017-03-30T08:47:58.612468+00:00 heroku[web.1]: Process exited with status 127
2017-03-30T08:47:58.623075+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-30T08:47:58.624221+00:00 heroku[web.1]: State changed from crashed to starting
2017-03-30T08:47:58.543010+00:00 app[web.1]: bash: npm: command not found
Let me know if there's anything I can do! If you think this might be a bug I'd be happy to try and create a pull request for it - I'd just need a bit of guidance on where in the source to look.
Hi sorry for the slow response. To be honest, I don't currently use this buildpack :(
All of the code is here: https://github.com/negativetwelve/heroku-buildpack-subdir/blob/master/bin/compile, this is the only file that compiles the app. Let me know what you find!
I am running into the exact same error with a Ruby build and buildpack. Everything is set up the same as your final solution, with the obvious difference being a bash: bundle : command not found
instead of not finding npm
. To add my findings:
I'm not sure what else there is to do here as there is no information about the inner working of the web dynos and nothing here that appears to be the culprit.
@bpruitt-goddard someone from Heroku opened an issue on the nodejs buildpack repo. It doesn't look like it has been picked up yet though.
Having said that, somebody did comment on it with an ad hoc solution for nodejs projects. I'm not sure what the equivalent of npm --prefix
and a package.json
is for Ruby projects, but you could potentially find an analogue for Ruby projects using his suggestion.
I had the same problem mentioned above so I created the following buildpack based on this one: https://github.com/Pagedraw/heroku-buildpack-select-subdir
It works for us. Let me know if it also works for you!
So the problem is that heroku buildpacks install things in .heroku
, and then set $PATH to include paths from /app/.heroku
. So, if you have a traditional node app, if you heroku run bash
and which php
, you'll see /app/.heroku/php/bin/php
. The other part of the problem is that if I use this buildpack, the same paths dont seem to get added to PATH
The solution is to:
heroku config:set PATH="heroku/php/bin:/app/.heroku/php/sbin:/app/.heroku/php/bin:/app/.heroku/php/sbin:/app/.heroku/php/bin:/app/.heroku/php/sbin:/app/.heroku/php/bin:/usr/local/bin:/usr/bin:/bin:/app/vendor/bin"
(or whatever the node buildpack adds to PATH)web: ln -sf laravel-api/.heroku && cd laravel-api && vendor/bin/heroku-php-apache2 public/
This adds the paths to your PATH
that the normal buildpack would have done, then it symlinks the .heroku
directory that got added to your subdirectory to where the PATH
is looking for it.
Different 3rd party buildpacks use different stuff. Like I also had to symlink .hex
and .platform_tools
for my elixir buildpack
works
@atomkirk It's a bit late, but a recent commit solved this:
@negativetwelve I think this one can be closed now :)
Firstly thank you for creating this! I need to deploy an app which is inside a repo's subdirectory (hence this issue).
However I've run into a problem. Even though the stdout of the deploy script seems to say that it has discovered the web process type, the logs then say that there is no web process declared. I don't understand how this is possible.
Deployment stdout
heroku logs --tail
Initially I only had a Procfile in the subdirectory, but then the deployment script didn't seem to pick up on it so I created a separate Procfile in the project root, but now it still doesn't seem to work.