What this guide covers
When you finish, each project switches to its own Node version when you enter its directory, and background jobs can find node too. You need: the command line tools installed, plus Homebrew if you choose fnm.
Steps
Pick one: nvm or fnm
Both install Node inside your own user directory. Neither needs an administrator password or touches system directories, which suits a rented machine. nvm has more users and fuller documentation, and it is a set of shell functions. fnm is a single executable that you can install and upgrade with Homebrew. Install only one, because two tools managing PATH at the same time will fight each other. We do not recommend
brew install nodeas your only source of Node:brew upgradewould replace Node for every project at once.Installing nvm: copy the command from the official README
The nvm install command contains the current version tag, which changes with each release, so we do not paste it here. Copy the latest line from the official nvm README. The README has two notes that matter on macOS: install the Xcode Command Line Tools first, and because the system has no
~/.zshrcby default, runtouch ~/.zshrcbefore the install script, otherwise it has nowhere to write its config. The README also states that installing nvm through Homebrew is not supported.Or install fnm
Following the official fnm README:
brew install fnm echo 'eval "$(fnm env --use-on-cd --shell zsh)"' >> ~/.zshrc--use-on-cdswitches versions automatically when you enter a directory that has a version file. Open a new terminal window after writing this before you continue.Install the LTS release and make it the default
nvm:
nvm install --lts, thennvm alias default node. fnm:fnm install --lts, then set the default withfnm default <version>. After that,node -vandnpm -vshould each print a version. We give no specific version number here: use whichever major version your project's own documentation asks for.Put a version file in every project
Put a
.nvmrcat the top level of the project (its content is just the version number) and commit it. With nvm, runnvm useafter entering the directory to read it. fnm with--use-on-cdreads.nvmrcor.node-versionautomatically. Your own computer and the remote Mac then run the same version, which removes one variable when you are working out why something runs locally but not remotely.Use the full path to node in background jobs
nvm and fnm both take effect through
~/.zshrc. Scheduled jobs and jobs that start at login do not read that file, so they report that node cannot be found. Most jobs on a remote machine run unattended, so you are more likely to hit this than on your own computer. The fix: runwhich nodein the terminal and write the full path into the job config, or have the job start throughzsh -lic 'your command'. The path changes when you upgrade Node, so remember to update it.Keep global packages in your user directory
With a Node installed by a version manager, the global package directory belongs to your own account.
npm install -gdoes not need elevated privileges and should not be run with them. If you get a permissions error, the Node in use is not the one from the version manager. Check withwhich nodefirst instead of changing the ownership of system directories. Global packages are separate for each version, so you need to reinstall them after switching.
FAQ
Package installs fail with "too many requests" or download errors. Why?
The public exit of this machine may be shared with other machines, so anonymous requests can hit upstream rate limits sooner, and speed also depends on the line and its load. Retry first. For private registries, log in with your own token and then install.
How do I install pnpm or yarn?
Corepack, which ships with Node, and each tool's official docs explain how; follow the official docs. The principle is the same: install into your user directory, and do not change system directories to install a package manager.
Should I remove old Node versions?
Yes. Every version takes disk space, along with its global packages. Review them with nvm ls or fnm list, and remove the ones you no longer use with nvm uninstall <version> or fnm uninstall <version>.
Related
- How to install Homebrew on a rented remote Mac mini and keep it maintained
- How to set up zsh on a remote Mac mini: config files, prompt and history
- How to schedule and auto-start jobs with user-level LaunchAgents on a remote Mac mini
- Can I install Node, Homebrew and Docker on a rented Mac mini myself?
- Remote Mac mini for heavy Claude Code use: an always-on workstation, not account insurance
Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support