msavir
msavir

Reputation: 11

Error `could not determine executable to run` on CI env when trying to run a nested bin script with NPX

First, everything works as expected on my local machine (macOS), but I'm getting errors when running it on CI (GitHub workflow) on Ubuntu.

My package uses a devDependency with an executable script that, in turn, uses another dependency with an executable script.

When running the devDep A bin script (with npx <command-a> ...), which internally runs the dep B bin script (with npx <command-b> ...), I get the error could not determine executable to run.

From the logs on CI, it appears that it tries to fetch command-b from the npm registry and then attempts to run a bin script within the package it finds—which that package doesn't have, leading to the error.

As I understand it, npm should try to find the npx command in the local node_modules, then in the global environment, and only if it doesn't find it would it attempt to fetch it from the npm registry. So, I assume the issue is that npm can't find command-b, and therefore it tries to fetch it from the npm registry.

Note: Running command-a with an option that doesn’t rely on command-b works as expected.

Here is the workflow file

name: Run tests

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    concurrency: ci-${{ github.ref }}-${{ github.workflow }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      # Install node
      - uses: actions/setup-node@v4
        with:
          node-version: "20"

      # Install pnpm
      - uses: pnpm/action-setup@v4
        with:
          version: 8.9.0

      - name: Install dependencies and run tests
        run: |
          cd examples/my-project
          pnpm install
          pnpm run test

pnpm run test runs the command-a script that relies on command-b

Note: tried with both npm and pnpm - nothing works.

I am not sure where the problem is, but since it works on my local environment, I suspect it is something with GH CI / Ubuntu / nested npx commands

Upvotes: 0

Views: 57

Answers (0)

Related Questions