nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
79.06k stars 7.92k forks source link

Shims for NVM #577

Open jalcine opened 9 years ago

jalcine commented 9 years ago

Having a shim for nvm (and others like node) would make it possible to use NVM under Vim (since Vim doesn't have the most elegant solution for loading in shell functions as pseudo-executables). This could help projects like Tern.

Caveats: Other things like the binaries used by node might not be discoverable immediately by node (might be wrong, working on PR to confirm this).

jalcine commented 9 years ago

It looks like the shim could just source in nvm/nvm.sh and pass it its arguments to nvm. Again, working on PR with tests.

koenpunt commented 9 years ago

What about nvm-exec?

ljharb commented 9 years ago

If a minimal PR can be made, great! However, please also consider creating a separate nvm.vim project if your changes might make more sense kept separately.

jalcine commented 9 years ago

@koenpunt That looks like a good basis to work with.

What it looks like is that shims have to be available via the $PATH variable. Took me a while to notice how that worked with projects like rbenv. I want to keep this as small as possible, for maintainability's sake.

matt-oakes commented 2 years ago

For anyone who sees this in the future, you can set this up yourself by creating a file in /usr/local/bin/node with these contents:

#!/usr/bin/env bash
~/.nvm/nvm-exec $@

This assumes that the .nvm directory is in your home folder (the default). Also make sure to set executable permissions with chmod +x /usr/local/bin/node.