Home > Back-end >  How can I make heroku/nodejs buildpack dump yarn logs into console instead of a tmp file?
How can I make heroku/nodejs buildpack dump yarn logs into console instead of a tmp file?

Time:11-27

Everything's sort of in the question, but here's some details. I have an monorepo structure like this, built on yarn workspaces:

my_app/
├─ node_modules/
├─ packages/
│  ├─ backend/
│  │  ├─ package.json/
│  │  ├─ Procfile/
│  ├─ frontend/
│  │  ├─ package.json/
│  │  ├─ Procfile/
│  ├─ common/
│  │  ├─ package.json/
├─ package.json/
├─ yarn.lock/

backend and frontend each depend on common, but not each other.

backend and frontend need to be deployed to Heroku. I used the heroku/heroku-buildpack-multi-procfile buildpack to set a Procfile per each application. So the buildpacks for backend are:

1. heroku/nodejs
2. heroku-community/multi-procfile

And for frontend:

1. mars/create-react-app
2. heroku-community/multi-procfile

Note: mars/create-react-app uses heroku/nodejs for its build step, so it looks like the issue is with that one.

As I push each one of them, they result in the same error that happens at Yarn's link step:

remote:        ➤ YN0000: ┌ Link step
remote:        ➤ YN0062: │ fsevents@patch:fsevents@npm:2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=1cc4b2 The platform linux is incompatible with this module, link skipped.
remote:        ➤ YN0062: │ fsevents@patch:fsevents@npm:1.2.13#~builtin<compat/fsevents>::version=1.2.13&hash=1cc4b2 The platform linux is incompatible with this module, link skipped.
remote:        ➤ YN0008: │ my-app@workspace:. must be rebuilt because its dependency tree changed
remote:        ➤ YN0008: │ bcrypt@npm:5.0.1 must be rebuilt because its dependency tree changed
remote:        ➤ YN0008: │ @nestjs/core@npm:8.1.1 [496a1] must be rebuilt because its dependency tree changed
remote:        ➤ YN0009: │ my-app@workspace:. couldn't be built successfully (exit code 127, logs can be found here: /tmp/xfs-9791b677/build.log)
remote:        ➤ YN0000: └ Completed in 7s 955ms
remote:        ➤ YN0000: Failed with errors in 1m 11s

As you see, it seems like it tries to build the root workspace (possibly that's the way it gets to build common?) and fails. It dumps its logs into a file, but as far as I know, it's impossible to see files generated during build process.

Here are my questions then:

  1. Is there a way to make it dump logs explicitly in the console?
  2. How can I simulate the same deploy process on my local? I looked through Heroku CLI docs and heroku/nodejs, but found only logs on running, not deploying.

Thanks for getting all the way down here! I must mention that I started working with Heroku yesterday, so I might still be missing something obvious - their logs are easy to get lost in. It's not my first time working with a managed software and I understand their general architecture.

CodePudding user response:

I've finally realized how to simulate the process on local: heroku/nodejs actually logs every step and every command it runs. You can find them, if in the dashboard you go to Your app -> Activity -> View build log (on one of the failed ones).

In my case yarn workspaces focus --all --production was failing and the problem was that I had a postinstall script that was installing husky, but husky itself is a dev dependency. I changed the postinstall script to prepare, which is postinstall that runs on dev only and it fixed the problem.

  • Related