See Ash Code logo See Ash Code

npx worked in Bash and disappeared in the MCP launcher

Ashlynn Antrobus
• • 3 min read

Antigravity couldn’t start my MCP server because it couldn’t find npx. In Bash, npx --help worked.

The launcher reported:

exec: "npx": executable file not found in $PATH

I had a working command in one environment and a missing executable in another. Reinstalling the package wasn’t the first thing I needed to do.

My shell was doing setup the launcher didn’t do

I used nvm to manage Node. My .bashrc contained lazy-loading functions for node, npm, and npx. Calling one of them loaded nvm and then ran the command.

Bash understood those functions. The MCP host was trying to start an executable by name, using its process environment. It didn’t have my interactive shell function standing in front of that lookup.

A Bash session demonstrating an alias, environment variables, and a nested shell.

A separate example of shell behavior: Bash demo by Chealer, GNU GPL version 2 or later; unmodified.

The two paths looked like this:

Interactive Bash
  npx function -> load nvm -> executable directory on PATH -> npx

MCP launcher
  executable lookup using inherited PATH -> npx not found

That explains why a command working at my prompt wasn’t enough evidence about the launcher’s environment.

An absolute path fixed only the first lookup

I found the nvm-managed executables under the same Node version directory and supplied the full path to npx.

That got npx started. Then the program it launched needed node, and that lookup had the same missing-PATH problem.

The executable path I supply for a parent doesn’t automatically rewrite the environment its children inherit. I needed the Node executable directory available throughout the launched process tree.

The repair was to initialize Node in the login/session environment before starting the launcher, so it inherited a PATH containing the actual executables. The same environment change was intended to address the failure in a local build script run by a test suite.

For a teaching example with a dummy home directory, the relevant part of that inherited environment would include:

/home/demo/.nvm/versions/node/v24.12.0/bin:/usr/local/bin:/usr/bin:/bin

The version is the one from this January incident. The important property is that the directory contains the real npx and node executables.

Startup files aren’t universal launch hooks

Moving initialization into .profile helps when the login/session path reads it and later launches inherit that environment. It doesn’t mean every noninteractive process reads .profile.

Bash’s startup-file rules distinguish login, interactive, and noninteractive shells. A launcher using an execution API may not start Bash at all.

I also didn’t want to put a machine-specific wrapper into the project’s build script. CI already had a working Node environment, and that local wrapper wouldn’t exist there. The parent-environment repair left the script without a dependency on my workstation’s wrapper. Troubleshooting stopped after that change; I don’t have a recorded fresh test run.

AA

Written by Ashlynn Antrobus

Software developer, author, and builder. Sharing technical lessons learned from building tools like Ebook2Text, IndexedDict, and rag-mcp, and navigating life as a programmer with dyslexia.