-
Notifications
You must be signed in to change notification settings - Fork 38
System‐wide installation
n-install
isn't really designed for system-wide installation, but you can do it with a few extra steps.
A possible use case is the need to run scripts using a different user identity.
Here's an example that installs to /usr/local/opt/n
, preinstalling the LTS node
version`:
curl -L https://git.io/n-install | N_PREFIX=/usr/local/opt/n bash -s -- lts
-
You may need
sudo
; on macOS, if you have Homebrew installed, you do not. If you do needsudo
, you'll later also need it to runn
and to install npm packages globally. -
While your shell initialization file(s) are still updated to define env. variable
N_PREFIX
and to add/usr/local/opt/n/bin
to thePATH
, you must also defineexport N_PREFIX=/usr/local/opt/n
in a global shell initialization file such as/etc/profile/
(sh
,bash
,ksh
) or/etc/zshenv
(zsh
); add the following line (requiressudo
):export N_PREFIX=/usr/local/opt/n; PATH+=":$N_PREFIX/bin"
In the simplest case:
sudo sh -c "echo 'export N_PREFIX=/usr/local/opt/n; export PATH+=\":\$N_PREFIX/bin\"' >>/etc/profile"
You must have
N_PREFIX
defined forn
to work properly, but if you'd rather not modify thePATH
env. variable, you can create symlinks in/usr/local/bin
as follows:cd /usr/local/bin ln -s ../opt/n/bin/* .
-
When you later uninstall
n
withn-uninstall
, you'll have to manually revert the changes to the global shell initialization files, and, if applicable, remove the manually createdn npm n-uninstall n-update
symlinks.