pnpm / action-setup

Install pnpm package manager
https://github.com/marketplace/actions/setup-pnpm
MIT License
887 stars 84 forks source link

Installing pnpm when the package.json isn't in the root directory #91

Closed lukey-aleios closed 1 year ago

lukey-aleios commented 1 year ago

Hi,

I'm working on a project with a separate backend & frontend directories, with individual package.json files. This step causes an issue for me because it fails when there isn't a package.json file in the top directory. Here's the line that is the likely culprit:

https://github.com/pnpm/action-setup/blob/0b715c7ebbf3cf2174d1386336c5f6d3d8d5504a/src/install-pnpm/run.ts#L14

Do you know any workaround for this?

KSXGitHub commented 1 year ago

You can either:

lukey-aleios commented 1 year ago

Ah, this was resolved! Nice work

konojunya commented 6 months ago

To make this issue clearer for those who see it, here are some important points on how to use pnpm/action-setup without putting package.json in the root directory.

If the above two points are satisfied, you can use pnpm/action-setup even if your project does not have package.json in root.

name: ci

on: push

jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: foo

    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v2
        with:
          version: 8
          run_install: |
            - args: [--frozen-lockfile]
              cwd: foo

ref: https://github.com/konojunya/not-root-pnpm-setup/actions/runs/7768165983/job/21185784600