Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npx / node not found using lazy node with zsh #131

Open
InTheCloudDan opened this issue Jan 4, 2025 · 0 comments
Open

npx / node not found using lazy node with zsh #131

InTheCloudDan opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@InTheCloudDan
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. MacOS, have zsh as your shell and use lazy node (below)
  2. try to run mcp dev server_module.py
  3. See error:
2025-01-04 10:55:05,882 - cli - ERROR - npx not found or failed to load. Please ensure Node.js and npm are properly installed and your shell initialization files are correctly configured.
2025-01-04 10:55:05,883 - cli - ERROR - npx not found. Please ensure Node.js and npm are properly installed and added to your system PATH.

lazy node shell script:

# Add every binary that requires nvm, npm or node to run to an array of node globals
NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`)
NODE_GLOBALS+=("node")
NODE_GLOBALS+=("nvm")
NODE_GLOBALS+=("npx")

# Lazy-loading nvm + npm on node globals call
load_nvm () {
  export NVM_DIR=~/.nvm
  [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
  if [ -f "$NVM_DIR/bash_completion" ]; then
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
  fi
}

# Making node global trigger the lazy loading
for cmd in "${NODE_GLOBALS[@]}"; do
  eval "${cmd}(){ unset -f ${cmd} >/dev/null 2>&1; load_nvm; ${cmd} \$@; }"
done

Expected behavior
A clear and concise description of what you expected to happen.

  • mcp dev server runs, it runs if I manually change the command to subprocess and source my ~/.zshrc

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS

Additional context
Add any other context about the problem here.

@dsp-ant dsp-ant added bug Something isn't working good first issue Good for newcomers labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants