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.
- Project
- devDep A // a dev dependency that includes a bin script
- dep B // a dependency that includes a bin script
- devDep A // a dev dependency that includes a bin 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 testson: pull_request: push: branches: - mainjobs: 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