How to Set Up Node.js for Running an Ethereum Smart Contract Project on Windows
Running Ethereum-based projects (such as smart-home DApps) requires a properly configured Node.js environment. This post documents step-by-step how the setup was completed on Windows, including verification of all installed tools.
1. Problem Encountered
When attempting to run Ethereum-related commands, the following error appeared:
bash: node: command not found
This indicates that Node.js was either not installed or not available in the system PATH.
2. Installing Chocolatey (Windows Package Manager)
Chocolatey is a package manager that simplifies software installation on Windows.
Step 1: Open PowerShell as Administrator
- Press Start
- Search for PowerShell
- Right-click → Run as Administrator
Step 2: Install Chocolatey
Run the Chocolatey installation script in PowerShell. Make sure to run PowerShell as Administrator and follow the prompts.
Step 3: Verify Chocolatey Installation
Restart the terminal and check:
choco -v
3. Installing Node.js (LTS Version)
The LTS (Long-Term Support) version of Node.js is recommended for blockchain and Ethereum development.
Step 1: Install Node.js
Run PowerShell as Administrator and type:
choco install nodejs-lts -y
If prompted: Do you want to continue? [Y/N] → Type Y
4. Verifying Node.js and npm Installation
After installation, close and reopen the terminal. Run:
node -v npm -v
Expected output (example):
v20.x.x 10.x.x
5. Navigating to the Ethereum Project Directory
Move to your Ethereum project folder:
cd ~/Documents/ethereum-smarthome/smart-home-ethereum
List project files:
ls
6. Installing Project Dependencies
Install required dependencies listed in package.json:
npm install
7. Testing the Ethereum Smart Contract Setup
Compile Smart Contracts
npx hardhat compile
Run Local Ethereum Node
npx hardhat node
8. Common Issues and Fixes
| Issue | Solution |
|---|---|
| node: command not found | Restart terminal, confirm PATH |
| Chocolatey permission error | Run PowerShell as Administrator |
| npm install fails | Delete node_modules and retry |
Final Confirmation
After completing all steps, confirm Node.js, npm, and Hardhat are working correctly:
node -v npm -v npx hardhat compile npx hardhat node
10. Conclusion
This guide demonstrated how to:
- Install Chocolatey
- Install Node.js (LTS)
- Verify Node.js and npm
- Prepare an Ethereum development environment on Windows
This setup enables local development, testing, and deployment of Ethereum smart contracts in a reliable and reproducible manner.
📌 Tips for Blogger:
- Click Insert Image → Upload from computer
- Use center alignment and medium/large size
- Add captions using italics for clarity
Comments
Post a Comment