Installing Node.js
This guide covers Node.js installation on Windows, macOS, and Linux. Node.js is a key dependency for HagiCode local tooling, including OpenSpec, frontend tooling, and several developer CLIs.
Version Requirements
HagiCode recommends Node.js 24+ (minimum supported Node.js >= 18.0). In most cases, install the latest LTS version and then verify that your version meets the requirement.
Installing Node.js
Method One: Official Installer (Recommended)
- Visit the Node.js Official Website
- Download the LTS (Long Term Support) version Windows installer (
.msifile) - Double-click to run the installer
- Follow the installation wizard prompts to complete installation:
- Accept the license agreement
- Choose installation path (default is fine)
- Make sure “Automatically install the necessary tools” is checked
- Click “Install” to start installation
- After installation completes, click “Finish”
Method Two: Using winget
Open PowerShell or Command Prompt and run:
winget install OpenJS.NodeJS.LTSAfter installation, reopen the terminal for changes to take effect.
Method One: Official Installer (Recommended)
- Visit the Node.js Official Website
- Download the LTS (Long Term Support) version macOS installer (
.pkgfile) - Double-click to run the installer
- Follow the installation wizard prompts to complete installation:
- Click “Continue”
- Accept the license agreement
- Choose installation disk
- Click “Install” and enter administrator password
- After installation completes, click “Close”
Method Two: Using Homebrew
If you have Homebrew installed, you can install Node.js via terminal:
brew install nodeHomebrew will automatically add Node.js to your PATH. If the command is not available, restart the terminal or run:
eval "$(/opt/homebrew/bin/brew shellenv)"Using NodeSource Repository (Recommended)
This is the best way to get the latest Node.js version:
# Use curl to download the installation scriptcurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -sudo apt-get install -y nodejsUsing apt Package Manager
If you don’t need the latest version, you can use the default Ubuntu repository:
sudo apt-get updatesudo apt-get install -y nodejs npmThe Node.js version in the default repository may be older. After installation, check the version to ensure it meets Node.js >= 18.0 requirements (Node.js 24+ is recommended).
Using NodeSource Repository (Recommended)
# Use curl to download the installation scriptcurl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -sudo yum install -y nodejsUsing yum Package Manager
sudo yum install -y nodejs npmUsing dnf Package Manager
sudo dnf install -y nodejs npmFedora’s software repository usually contains newer Node.js versions and can be installed directly via dnf.
Using Version Management Tools
If you need to switch between multiple Node.js versions, you can use version management tools.
nvm (Node Version Manager)
Linux/macOS
# Install using curlcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Or install using wgetwget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bashAfter installation, reload your shell configuration:
source ~/.bashrc# Or for Zsh userssource ~/.zshrcWindows
On Windows, we recommend using nvm-windows:
- Download the latest
nvm-setup.exefrom nvm-windows releases - Run the installer
- Reopen Command Prompt or PowerShell
After installing nvm, you can use it to install and manage Node.js versions:
# Install the latest LTS version (recommended)nvm install --lts
# Install Node.js 24 (recommended version)nvm install 24
# Install a specific Node.js versionnvm install 18.20.0
# List installed versionsnvm list
# Switch to a specified Node.js versionnvm use 24
# Set default versionnvm alias default 24
# Windows nvm-windows syntax is slightly differentnvm install 24nvm use 24fnm (Fast Node Manager)
fnm is a faster and simpler Node.js version management tool built with Rust.
Linux/macOS
# Install using curlcurl -fsSL https://fnm.vercel.app/install | bash
# After installation, reload shell configurationsource ~/.bashrc# Or for Zsh userssource ~/.zshrcWindows
# Use scoopscoop install fnm
# Or use wingetwinget install Schniz.fnm# Install the latest LTS version (recommended)fnm install --lts
# Install Node.js 24 (recommended version)fnm install 24
# Install a specific Node.js versionfnm install 18.20.0
# List installed versionsfnm list
# Switch to a specified Node.js versionfnm use 24
# Set default versionfnm default 24Acceleration for Mainland China Users
If you are in Mainland China, downloading Node.js and npm packages may be slow. Here are some acceleration solutions.
Using Domestic Mirror Sources
npm Taobao Mirror (Recommended)
# Temporarily use Taobao mirrornpm install --registry=https://registry.npmmirror.com
# Permanently set Taobao mirrornpm config set registry https://registry.npmmirror.com
# Verify mirror is set successfullynpm config get registryUsing nrm to Manage Mirror Sources
nrm (npm registry manager) helps you quickly switch npm mirror sources:
# Install nrmnpm install -g nrm
# List available mirror sourcesnrm ls
# Switch to Taobao mirrornrm use taobao
# Test mirror source speednrm testAccelerating Node.js Installer Downloads
Taobao provides mirror downloads for Node.js installers:
- Download Address: https://npmmirror.com/mirrors/node/
Visit the above address and select the version you need to download.
If downloading nvm or other tools from GitHub is slow, you can use the FastGit mirror:
# Use FastGit to accelerate nvm installationcurl -o- https://fastgit.org/nvm-sh/nvm/raw/master/install.sh | bashFastGit service may change, please refer to official information.
Domestic Homebrew Mirrors
If you use Homebrew in Mainland China, you can configure domestic mirrors for acceleration:
# Install Homebrew using domestic mirror/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
# Or use USTC mirrorexport HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottlesMainland China Specific Package Managers
cnpm
cnpm is an npm client provided by the Taobao team that uses the Taobao mirror by default:
# Install cnpmnpm install -g cnpm --registry=https://registry.npmmirror.com
# Use cnpm to install packagescnpm install <package-name>cnpm is mostly compatible with npm commands and can be used as a direct replacement.
Verifying Mirror Acceleration Effect
After setting up mirrors, verify by:
# Test download speedtime npm install express --registry=https://registry.npmmirror.com
# Compare with official source speedtime npm install express --registry=https://registry.npmjs.orgVerifying Installation
After installation, verify that Node.js and npm are installed correctly:
# Check Node.js versionnode --version
# Check npm versionnpm --versionMake sure Node.js version >= 18.0 (Node.js 24+ is recommended). If the version is too low, please reinstall using the above methods or use version management tools to install the correct version.
Sample Verification Output
Successful verification output should look like:
$ node --versionv24.3.0
$ npm --version10.2.3Troubleshooting
Windows Issues
If node or npm commands are not available after installation:
- Restart Command Prompt or PowerShell
- If still not available, manually add Node.js to PATH:
- Search for “Environment Variables” and open “Edit system environment variables”
- Click “Environment Variables”
- Find “Path” in “System variables” and click “Edit”
- Add Node.js installation path (default:
C:\Program Files\nodejs\) - Click “OK” to save changes
If you encounter execution policy errors when using nvm:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUsermacOS Issues
If you encounter permission errors when installing global npm packages:
# Fix npm permissionssudo chown -R $(whoami) ~/.npmsudo chown -R $(whoami) /usr/local/lib/node_modulesIf commands are not available after installation, restart the terminal or manually add to PATH (usually in /usr/local/bin).
Linux Issues
If you encounter permission errors when installing global npm packages, it is recommended to use Node.js version management tools (like nvm or fnm) instead of system package managers.
If the Node.js version installed via system package manager is too old:
- Use NodeSource repository (recommended, see above)
- Or use version management tools (nvm/fnm)
Checking Environment
If verification fails, check the following:
# Check if Node.js is in PATHwhere node
# Check installation pathGet-Command node# Check if Node.js is in PATHwhich node
# Check installation pathls -l $(which node)# Check if Node.js is in PATHwhich node
# Check installation pathls -l $(which node)
# Check version detailsnode -vNext Steps
After Node.js installation is complete, you can continue with the following steps:
Need More Help?
If you encounter issues not covered here:
- Visit the Node.js Official Documentation
- Review the HagiCode Product Overview for current product and tooling context
- Visit the HagiCode website for the latest support entry points