Question about Running a Shell Script

I am trying to automate running a Node app but it is not working

These are the contents of a Shell script called codatest.sh in my Node project directory:

#!/bin/bash

cd /Users/richardkaplan/github-repositories/pubmed-pack

npx coda execute  /Users/richardkaplan/github-repositories/pubmed-pack/pack.ts PubMed 27919949

If open the terminal then from the pubmed-pack directory I can run the script file fine

However if I go to KM and try to execute the script I get an error saying "npx not found"

Execute a Shell Script.kmactions (793 Bytes)

Suggestions?

1 Like

Execute a Shell Script provides a pristine vanilla shell
(not the customized one used by Terminal.app)
so you need to specify the full path to the executable.

Path in Shell Scripts [Keyboard Maestro Wiki]


use the incantation:

which npx

(from Terminal.app)

to find the full path.


See also:

Replicate $PATH From Your Terminal.app Environment to Keyboard Maestro - Macro Library - Keyboard Maestro Discourse

4 Likes

Oh, yes, I remember discovering this the hard way. And then discovering it again. And again.

1 Like