Install Node.js & npm
Before you can develop smart contracts on WireFluid using professional tools like Hardhat, you need to install Node.js and npm (Node Package Manager).
ℹ️ Quick Info
Time Required: ~5-10 minutes
Difficulty: Beginner
What You’ll Install: Node.js v18 or higher and npm (included with Node.js)
What is Node.js?
Node.js is a JavaScript runtime that allows you to run JavaScript code outside of a web browser. It’s essential for:
- Running development tools like Hardhat and Foundry
- Installing and managing smart contract libraries
- Compiling and deploying contracts from the command line
- Running automated tests for your contracts
npm (Node Package Manager) comes bundled with Node.js and is used to install JavaScript packages and dependencies.
System Requirements
Before installing, ensure your system meets these requirements:
| Requirement | Description |
|---|---|
| Operating System | macOS, Windows 10/11, or Linux (Ubuntu, Debian, Fedora) |
| Disk Space | At least 500 MB of free disk space |
| RAM | Minimum 4 GB (8 GB recommended) |
| Internet Connection | Required for downloading packages |
Check if Node.js is Already Installed
Before installing, check if Node.js is already on your system:
Step 1: Open your terminal
- macOS: Press
Cmd + Space, type “Terminal”, and press Enter - Windows: Press
Win + R, type “cmd”, and press Enter - Linux: Press
Ctrl + Alt + T
Step 2: Check Node.js version
node --versionStep 3: Check npm version
npm --versionIf you see version numbers:
- Node.js version should be v18.0.0 or higher
- npm version should be 9.0.0 or higher
If your versions are lower, follow the installation steps below to update.
⚠️ Warning
Node.js v16 and below are no longer supported. Make sure to install v18 or higher for compatibility with modern development tools.
Installation Instructions
Choose your operating system:
macOS
Click to expand macOS instructions
There are two recommended methods for installing Node.js on macOS:
Method 1: Using Homebrew (Recommended)
Homebrew is a package manager for macOS that makes installing software easy.
Step 1: Install Homebrew (if not already installed)
Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Follow the on-screen instructions. You may need to enter your password.
Step 2: Install Node.js
brew install node@20This installs Node.js version 20 (LTS - Long Term Support).
Step 3: Verify installation
node --version
npm --versionYou should see:
v20.x.x
10.x.xMethod 2: Using Official Installer
Step 1: Download the installer
Visit nodejs.org and download the LTS (Long Term Support) version for macOS.
Step 2: Run the installer
- Open the downloaded
.pkgfile - Follow the installation wizard
- Click “Continue” through all steps
- Enter your password when prompted
- Click “Install”
Step 3: Verify installation
Open Terminal and run:
node --version
npm --version💡 Tip: If the commands are not recognized, close and reopen your Terminal to refresh the environment variables.
Updating Node.js on macOS
If you installed via Homebrew:
brew upgrade nodeIf you used the official installer, download and run the latest installer from nodejs.org.
Windows
Click to expand Windows instructions
Step 1: Download the installer
Visit nodejs.org and download the LTS (Long Term Support) version for Windows.
Choose the Windows Installer (.msi) for your system:
- 64-bit (most common)
- 32-bit (older systems)
Step 2: Run the installer
- Double-click the downloaded
.msifile - Click “Next” on the welcome screen
- Accept the license agreement
- Choose the installation location (default is fine)
- Keep all default features selected (especially “Add to PATH”)
- Click “Install”
- Wait for installation to complete
- Click “Finish”
Step 3: Verify installation
Open Command Prompt (press Win + R, type cmd, press Enter) and run:
node --version
npm --versionYou should see:
v20.x.x
10.x.x⚠️ Important: Make sure “Add to PATH” is checked during installation. This allows you to run
nodeandnpmcommands from any directory.
Alternative: Using Windows Package Manager (winget)
If you have Windows 10/11 with winget:
winget install OpenJS.NodeJS.LTSUpdating Node.js on Windows
Download and run the latest installer from nodejs.org. The new version will automatically replace the old one.
Troubleshooting Windows Installation
Command not found error:
- Close and reopen Command Prompt
- If still not working, add Node.js to PATH manually:
- Search “Environment Variables” in Windows
- Click “Environment Variables”
- Under “System variables”, find “Path”
- Add:
C:\Program Files\nodejs\
Linux
Click to expand Linux instructions
Ubuntu / Debian
Step 1: Update package index
sudo apt updateStep 2: Install Node.js from NodeSource
NodeSource maintains up-to-date Node.js packages for Debian/Ubuntu.
For Node.js 20.x LTS:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejsStep 3: Verify installation
node --version
npm --versionℹ️ Note: The default Ubuntu repositories often have outdated Node.js versions. Using NodeSource ensures you get the latest LTS release.
Updating Node.js:
sudo apt update
sudo apt upgrade nodejsFedora / RHEL / CentOS
Step 1: Install Node.js from NodeSource
For Node.js 20.x LTS:
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo dnf install -y nodejsFor CentOS/RHEL 7:
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejsStep 2: Verify installation
node --version
npm --versionUsing NVM (Node Version Manager) - Recommended for Linux
NVM allows you to install and switch between multiple Node.js versions easily.
Step 1: Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashStep 2: Reload your shell configuration
source ~/.bashrc
# or
source ~/.zshrcStep 3: Install Node.js
nvm install 20
nvm use 20
nvm alias default 20Step 4: Verify installation
node --version
npm --versionBenefits of NVM:
- Switch between Node.js versions easily
- No need for
sudowhen installing packages globally - Perfect for testing across different Node.js versions
Common NVM commands:
nvm list # List installed versions
nvm install 18 # Install Node.js 18
nvm use 18 # Switch to Node.js 18
nvm alias default 20 # Set default versionPost-Installation Configuration
After installing Node.js and npm, follow these steps to optimize your setup:
1. Configure npm for Global Packages
By default, npm installs global packages to a system directory that requires administrator privileges. Change this to a local directory:
macOS/Linux:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'Add this line to your ~/.bashrc, ~/.zshrc, or ~/.bash_profile:
export PATH=~/.npm-global/bin:$PATHReload your shell:
source ~/.bashrc
# or
source ~/.zshrcWindows:
npm config set prefix "%APPDATA%\npm"The PATH should be updated automatically. If not, add %APPDATA%\npm to your system PATH.
2. Update npm to Latest Version
Even though npm comes with Node.js, you can update it to the latest version:
npm install -g npm@latestVerify the update:
npm --version3. Test Your Installation
Create a test file to ensure everything works:
mkdir ~/test-node
cd ~/test-node
echo "console.log('Node.js is working!');" > test.js
node test.jsYou should see:
Node.js is working!Essential npm Commands
Now that you have npm installed, here are the most common commands you’ll use:
# Install a package locally (in your project)
npm install <package-name>
# Install a package globally (available system-wide)
npm install -g <package-name>
# Install all dependencies from package.json
npm install
# Initialize a new Node.js project
npm init
# Check for outdated packages
npm outdated
# Update packages
npm update
# Uninstall a package
npm uninstall <package-name>Installing Development Tools for WireFluid
Now that Node.js and npm are installed, you can install the tools needed for WireFluid development:
Install Hardhat (Recommended)
npm install -g hardhatVerify installation:
npx hardhat --versionInstall TypeScript (Optional but Recommended)
npm install -g typescriptInstall pnpm (Alternative to npm, faster)
npm install -g pnpm💡 What’s next? After installing Node.js and npm, proceed to Setup MetaMask Wallet to configure your blockchain wallet.
Troubleshooting
Common Issues and Solutions
”node: command not found”
Solution:
- Close and reopen your terminal
- Check if Node.js is in your PATH:
echo $PATH - Reinstall Node.js and ensure “Add to PATH” is selected
”npm: command not found” (but Node.js works)
Solution:
# macOS/Linux
brew reinstall node
# Windows
# Reinstall Node.js from nodejs.orgPermission denied when installing packages globally
Solution:
- DON’T use sudo with npm!
- Follow the Post-Installation Configuration steps above
- Or use NVM instead
”EACCES: permission denied” errors
Solution (macOS/Linux):
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modulesSlow npm installations
Solution:
- Clear npm cache:
npm cache clean --force - Use a faster package manager:
npm install -g pnpm
Different Node.js version needed for different projects
Solution: Use NVM to manage multiple versions:
nvm install 18
nvm install 20
nvm use 18 # Switch to Node 18
nvm use 20 # Switch to Node 20Verifying Your Setup
Run this comprehensive check to ensure everything is properly installed:
# Check Node.js version
node --version
# Check npm version
npm --version
# Check if npx is available (comes with npm 5.2+)
npx --version
# Test Node.js execution
node -e "console.log('Node.js is working')"
# Test npm by listing global packages
npm list -g --depth=0Expected output:
v20.x.x
10.x.x
10.x.x
Node.js is working
/usr/local/lib
└── npm@10.x.xNext Steps
Now that Node.js and npm are installed, continue with the prerequisites:
- Setup MetaMask Wallet → - Install and configure your blockchain wallet
- Configure WireFluid Network → - Connect MetaMask to WireFluid
- Get Testnet Tokens → - Request free test $WIRE
- Choose Your Development Path → - Remix, Hardhat, or Foundry?
Additional Resources
- Official Node.js Documentation
- npm Documentation
- NVM GitHub Repository
- Hardhat Documentation
- Node.js Best Practices
Success!
Congratulations! You’ve successfully installed Node.js and npm. You’re ready to start building on WireFluid!