pd4d10 / nn

A full featured, cross platform, zero dependencies Node.js version manager
MIT License
20 stars 2 forks source link

Document how it works #3

Open luxzeitlos opened 6 years ago

luxzeitlos commented 6 years ago

nvm can be quite annoying because it hooks deep into the shell. I've used nodenv so far on *nix, and I really like how transparent the functionality is. The usage of shims means I dont need any setup code that slows down my shell boot, or any hooks into my shell. I just need to nodenv rehash when I install a new global binary the first time. This especially also makes it compatible with exotic shells like fish.

I would love if nn could become a unified solution that would also work on windows (the one think I dont have with nodenv).

However for now its very unclear how nn handles switching global binaries. Does it manipulate the PATH or does it use something like shims?

pd4d10 commented 6 years ago

@luxferresum In brief, nn add PATH once at installation. It does not change PATH when using it.

The PATH added are:

See install.sh and install.ps1 for more details.

Thanks for your suggestion. Any idea or pull request is welcome.

luxzeitlos commented 6 years ago

Thanks for clarification. I just realised that nn is far simpler because it does not allow local or shell specific installations. Do you want to keep it that way?

pd4d10 commented 6 years ago

@luxferresum Do you mean manual installation? Just do the following steps:

The install script just did these things. It will detect the default shell, then add PATH to it. For now only zsh and bash are handled.

Maybe we should add a section in README for users who use other shell like fish

luxzeitlos commented 6 years ago

Thanks! Yes, documentation for manual installation would be nice.

And no, my question was about shell-specific or local node versions. nvm has the .nvmrc, nodenv the .node-version. Both allow shell specific node versions, or even to specify a node version per folder. This is not possible with nn. However this seems to be the reason that nn is so simple; it can just guarantee that ~/.nn/current contains the right files. However with this approach you cant support local versions. So I was asking if you plan to keep it that way and not to support local versions?

pd4d10 commented 6 years ago

It's an interesting point. Seems they dynamically change PATH for every shell instance, while nn just use soft link. So if you run nn use 10.8.0, all shell instances will have 10.8.0 activated because they all point to current soft link.

Seems Nodenv's shims is a reasonable resolution. We'll investigate pros and cons of using such a mechanism