macOS Shell vs. Terminal

I’m trying to do some basic git and node / npm commands in Xojo via Shell.
I installed git and Node.JS on our Mac and everything is fine if I check the version in the Terminal:

Bildschirmfoto 2021-11-12 um 08.04.09

If I want to do the same in Xojo via Shell I have a problem.
Git works but node or npm is not found:

Var s As New Shell
s.Execute "node --version"

MessageBox s.Result

bash: node: command not found

Any ideas how to solve this?

You need to use the full path like “usr/bin/node” or wherever node is installed.

Or add the System.EnvironmentVariable(“PATH”) output to the Shell using the commands (class mus remain active using the interactive runmode. But you can however sync the environment to the system if you wished.

Do you have some sample code how I can achieve this?

// Sh = Shell in Interactive mode.
Sh.Execute("export PATH=" + System.EnvironmentVariable("PATH"))
Sh.Execute("node --version")

An alternative is to set the path yourself:

// Sh = Shell in Interactive mode.
Sh.Execute("export PATH=/path/to/node/js/bin/folder:/another/path"))
Sh.Execute("node --version")

Some thing like that, how you export the path is different on platforms. Since xojo’s shell class is an empty environment, you could/should set the env yoursef using this way or env files…

This results for me in:


please verify the System.EnvironmentVariable output first in a property.
Then please show the output of “echo $PATH” in your shell.

Maybe you could use: “cd /path/to/node/root/folder” perhaps it’s worth a try.