I think you'll find that it's always the same issue when a question title includes "Shell Script". (The question is asked dozens of times every year, and you will find quite a lot of coverage of it here).
The point is that (fortunately for debugging, script sharing etc etc) an Execute Shell Script action gets a pristine vanilla instance of the shell.
It doesn't depend on, and not related to, the instance set up by other applications like Terminal.app, and it needs you to either:
Define a value for $PATH which includes the path to application which you want to call,
or directly supply the full path to applications like code
On this system, for example, I would replace:
For a more generic and local approach, see, for example:
It's mainly a user-issue -- but an understandable one given the complexities. For example, in Terminal/iTerm you are in an "interactive shell", which reads different config files when it starts than a KM "Execute Shell Script" action, a "non-interactive" shell, does. That's just the way shells work.
The PATH issue in particular is documented on the action's Wiki page -- it isn't a particularly easy read, but that's because it's a complicated subject!