Skip to content

Latest commit

 

History

History
105 lines (83 loc) · 4.99 KB

SETUP.md

File metadata and controls

105 lines (83 loc) · 4.99 KB

NVS Setup

NVS currently works on any platform for which Node.js binaries are available. The ability to build and install Node.js from source may be added later.

Before installing, decide on either a single-user installation or a system installation:

  • For individual development, a single-user installation is recommended because then NVS does not require root/admin privileges for any commands.
  • If multi-user functionality is desired, or if NVS should be able to link a version as a system Node.js installation, then it may be installed to a system folder. Adding, removing, or linking node versions will then require root/admin privileges, but using a node version will not.

By default, downloaded Node.js files are cached under the NVS installation directory. To override this behavior, set the NVS_HOME environment variable to another location.

Windows

NVS requires PowerShell 3.0, which is included with Windows 8 and later. On Windows 7, get PowerShell 3.0 from Windows Management Framework 3.0 (which requires Windows 7 Service Pack 1).

Download and run the Windows Installer (MSI) package from the Releases page on GitHub. Note the single MSI package supports both x86 and x64 systems and both per-user and per-machine installations.

As an alternative to installing the MSI, the following manual steps may be used to setup NVS on Windows, from either a Command Prompt or PowerShell.

Manual setup - Command Prompt

  1. Specify the installation path using one of the following commands, for either a single-user or system installation:
set NVS_HOME=%LOCALAPPDATA%\nvs
set NVS_HOME=%ProgramData%\nvs
  1. Clone this repo:
git clone https://github.com/jasongin/nvs "%NVS_HOME%"
  1. Run the install command:
"%NVS_HOME%\nvs.cmd" install

Manual setup - PowerShell

  1. Specify the installation path using one of the following two commands:
  • For a current-user installation (recommended):
$env:NVS_HOME="$env:LOCALAPPDATA\nvs"
  • Or for a system installation:
$env:NVS_HOME="$env:ProgramData\nvs"
  1. Clone this repo:
git clone https://github.com/jasongin/nvs "$env:NVS_HOME"
  1. Run the install command:
. "$env:NVS_HOME\nvs.ps1" install

After installation, running just nvs from the current shell or any new Command Prompt or PowerShell then invokes either the nvs.cmd or nvs.ps1 script accordingly.

Git Bash on Windows

NVS can work in Git Bash on Windows (the bash tools installed by Git for Windows).

  1. Install NVS using Git Bash (see instructions: Mac, Linux ).

  2. Ensure there is a .bash_profile file in your home ($HOME) directory that calls .bashrc. Create the file if it doesn't exist. It should include at least the following line:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

.bashrc file is created by NVS if it does not exists.

Ubuntu Bash on Windows 10

NVS can also work in Ubuntu Bash on Windows 10 using the following installation instructions for Linux. Be aware that instance of NVS and any Node.js versions it installs in that environment are only available to the Ubuntu subsystem. It actually downloads and runs the Node.js Linux binaries, not the Windows binaries.

Mac, Linux

  1. Specify the installation path using one of the following two commands:
  • For a current-user installation (recommended):
export NVS_HOME="$HOME/.nvs"
  1. Clone this repo:
git clone https://github.com/jasongin/nvs "$NVS_HOME"
  1. Source the install command:
. "$NVS_HOME/nvs.sh" install
  • Or for a system installation:

    NVS_HOME must still be set to a user-writable directory, e.g. ~/.nvs, not to the directory containing the nvs script files. NVS_HOME is where the user-specified node versions will be downloaded and cached, and also where the temporary .sh file can be written.

export NVS_HOME="$HOME/.nvs"
  1. Clone this repo:
sudo git clone https://github.com/jasongin/nvs /opt/nvs
  1. Run the install command:
/opt/nvs/nvs install

The nvs.sh script adds an nvs shell function to the environment. Afterward the tool should be invoked as just nvs without any path. The install command also adds lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to source nvs.sh, so that the nvs function is available in future shells.

Note there is also an executable shell script named nvs (without the .sh), that may be used to invoke the tool without having to first source nvs.sh. However, when invoked in that way the script cannot update the caller's environment, so the nvs use command is disabled. And there is a nvsudo shell function that invokes nvs under sudo while preserving the PATH (and thus the current node version). The latter may be helpful when NVS is installed in a system directory.