Fix 'npm error code ENOENT' in install.ps1 on Windows
Installer crashes with ENOENT? Refresh your PATH or reinstall Node.
AI Deployment Reality Check
If your agent runtime can reach your filesystem and localhost services, a single malicious plugin or prompt can turn into data exposure. Isolation is the lowest-effort mitigation.
Switch to Secure Cloud SandboxSecure Infrastructure | DeepSeek R1 Ready
TL;DR: The Instant Fix
The Problem: The
install.ps1script detects Node.js but crashes withnpm error code ENOENTwhen trying to install dependencies.The Error:
npm error code ENOENTduringinstall.ps1executionThe Solution:
- Quick Fix: Close PowerShell and reopen (PATH hasn't updated yet)
- Real Fix: Reinstall Node.js to the default path
Deploy on Vultr (High Availability & Free Credit) (Windows PATH issues are a headache. Linux just works.)
⚠️ Stop debugging for a second.
If you are on a personal Windows PC, this error is often a symptom of "Environment Mismatch". Before you spend hours fixing paths, check if your hardware is actually safe for running AI agents locally.
The Log: What You're Seeing
The Error:
PS C:\openclaw> .\install.ps1
[INFO] Checking prerequisites...
[INFO] Node.js found: v18.x.x
[INFO] npm found: 9.x.x
[INFO] Installing dependencies...
npm error code ENOENT
npm error path C:\openclaw\node_modules\@m1heng
npm error errno -4058
npm error syscall mkdir
npm error enoent ENOENT: no such file or directory, mkdir 'C:\openclaw\node_modules\@m1heng'
npm error A complete log of this run can be found in: C:\Users\YourName\AppData\Local\npm-cache\_logs\2026-02-04T10_23_45_123Z-debug-0.log
[ERROR] Installation failed
Context: This error occurs during the initial install.ps1 setup on Windows. The script detects Node.js and npm correctly, but crashes when trying to install OpenClaw dependencies.
Observed Behavior:
install.ps1says "Node.js found" and "npm found"- Installation starts but immediately fails with ENOENT
- Re-running
install.ps1gives the same error
Why This Happens (It's a PATH Issue)
This is a Windows PATH Refresh Issue.
The install.ps1 script assumes:
- Node.js is accessible via the PATH variable
- npm is available in the same location
- PATH is current (not cached from an old shell)
But on Windows, you're seeing:
- Node.js was just installed but PATH hasn't refreshed
- PowerShell is using cached PATH from before Node installation
- npm exists but PowerShell can't see it in the current session
The error ENOENT means: "Error NO ENTry" — Windows can't find the npm executable, even though it reports as "found" during the prerequisite check.
Why install.ps1 Says "npm found" But Fails
| Phase | What install.ps1 Checks | What Actually Happens |
|---|---|---|
| Prerequisite Check | Queries Node.js version | Uses cached PATH, finds Node |
| npm Detection | Queries npm version | Uses cached PATH, finds npm |
| Dependency Install | Calls npm install (may spawn git) | Tries to use npm/git from cached PATH → ENOENT |
Common Cause: Missing Git
npm often tries to spawn git to fetch packages from GitHub. If git.exe is missing from PATH:
npm error syscall spawn git
npm error code ENOENT
The Fix: Install Git for Windows and add it to PATH.
The issue is that PowerShell caches the PATH environment variable. When you install Node.js, it updates PATH in the registry, but your open PowerShell session still has the old PATH.
⚠️ Critical Crash Warning
If this step fails not with an error message, but with a sudden crash or
spawn EINVAL, do not keep retrying. Your environment may be corrupted. Go to the Spawn EINVAL Decision System →
Solution A: Close and Reopen PowerShell (Most Likely Fix)
This is the fix that works 90% of the time. You just installed Node.js, but your PowerShell session doesn't know about it yet.
Step 1: Close PowerShell COMPLETELY
# Type this to exit PowerShell
exit
# Or just close the window directly
# IMPORTANT: Make sure ALL PowerShell windows are closed
Step 2: Open a FRESH PowerShell
Press Win + X, then select "Windows PowerShell" or "Terminal"
This NEW PowerShell session will read the updated PATH from the registry.
Step 3: Verify Toolchain (Node & Git)
# Check if npm is in your PATH
where.exe npm
# Should output something like:
# C:\Program Files\nodejs\npm.cmd
# Check if Git is installed
git --version
# Should output something like:
# git version 2.x.x
# If you see "INFO: Could not find files for the given pattern(s)",
# your PATH is still not updated. Restart your computer.
If
gitcommand is not found:OpenClaw needs Git to download dependencies. npm often tries to spawn
gitto fetch packages from GitHub. Ifgit.exeis missing from PATH, Windows throwsENOENT.👉 Download Git for Windows: https://git-scm.com/download/win
(Select "Run Git from the Windows Command Prompt" during install)
Step 4: Run install.ps1 Again
cd C:\openclaw
.\install.ps1
# Should work now
Why This Works: Closing PowerShell forces it to forget the cached PATH. When you reopen it, Windows reads the fresh PATH from the registry, which now includes Node.js.
Solution B: Restart Your Computer (If Reopening PowerShell Didn't Work)
If closing PowerShell didn't fix it, Windows might be holding onto the old PATH system-wide.
Step 1: Save Your Work
Close any open applications.
Step 2: Restart Windows
# Or use the GUI: Start → Power → Restart
Restart-Computer
Step 3: Open PowerShell After Restart
# Verify npm is found
where.exe npm
# Should show: C:\Program Files\nodejs\npm.cmd
Step 4: Run install.ps1
cd C:\openclaw
.\install.ps1
Why This Works: A restart forces ALL processes (including Windows services) to reload environment variables from the registry.
Solution C: Reinstall Node.js to Default Path (Permanent Fix)
If the above solutions don't work, Node.js might be installed in a non-standard location.
Step 1: Uninstall Existing Node.js
# Open Programs and Features
appwiz.cpl
# Find "Node.js" and uninstall it
Step 2: Download Latest LTS
https://nodejs.org/en/download/
Choose: Windows Installer (.msi)
Step 3: Install to Default Location
During installation:
- ✅ Accept default path:
C:\Program Files\nodejs - ✅ Check "Add to PATH" (should be checked by default)
- ✅ Complete the installation
Step 4: Restart PowerShell and Verify
# Close and reopen PowerShell
where.exe npm
# Should output: C:\Program Files\nodejs\npm.cmd
# If it works, run install.ps1
cd C:\openclaw
.\install.ps1
The "Survival" Recommendation
Stop fighting Windows PATH issues.
Every hour you spend debugging environment variables, restarting shells, or reinstalling Node.js is an hour you're not shipping.
Windows PATH issues are a headache. Linux just works.
Local Windows vs Cloud VPS Comparison
| Issue | Local Windows | Cloud VPS (Vultr) |
|---|---|---|
| Node.js installation | Manual, PATH issues | Pre-installed, configured |
| npm in PATH | Requires shell restart | Already working |
| install.ps1 | May need multiple retries | Works immediately |
| Environment setup | 1-3 hours (with debugging) | 2 minutes |
| Cost | "Free" (but your time = billable hours) | Hourly billing options |
Deploy on Vultr (High Availability & Free Credit) (Windows PATH issues are a headache. Linux just works.)
Complete Working Example
Verified Windows Configuration
# 1. Install Node.js 18+ LTS from https://nodejs.org/
# Download: Windows Installer (.msi)
# Install to: C:\Program Files\nodejs (default)
# 2. Close ALL PowerShell windows
exit
# 3. Open FRESH PowerShell
# Press Win + X → Windows PowerShell
# 4. Verify Node.js, npm, and Git are in PATH
node --version
# Output: v18.x.x or higher
npm --version
# Output: 9.x.x or higher
git --version
# Output: git version 2.x.x
where.exe npm
# Output: C:\Program Files\nodejs\npm.cmd
# 5. Navigate to OpenClaw directory
cd C:\openclaw
# 6. Run install.ps1
.\install.ps1
# Success: Installation completes without ENOENT errors
If It Still Fails
# Verify the install.ps1 script exists
ls .\install.ps1
# Check execution policy
Get-ExecutionPolicy
# If Restricted, set to RemoteSigned
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
# Try running with explicit PowerShell
powershell -ExecutionPolicy Bypass -File .\install.ps1
FAQ
Q: install.ps1 says "npm found" but still crashes with ENOENT?
A: The prerequisite check uses cached PATH, but the actual npm call during dependency installation fails because the PATH is stale. Close PowerShell completely and reopen it. This fixes it 90% of the time.
Q: I just installed Node.js, why doesn't PowerShell see it?
A: PowerShell caches environment variables including PATH. When you install Node.js, it updates PATH in the registry, but your open PowerShell session still has the old PATH cached. You must close PowerShell and reopen it (or restart your computer) to refresh the cache.
Q: What's the difference between this error and the 'spawn npm ENOENT' error?
A: This error happens during install.ps1 (initial setup). The "spawn npm ENOENT" error happens when OpenClaw tries to install plugins. Both are PATH issues, but at different stages. See our [plugin install ENOENT fix guide](/guides/fix-openclaw-spawn-npm-enoent-windows) for that error.
Q: Do I need to restart my entire computer?
A: Usually not. Closing PowerShell and reopening it is enough. Restart your computer only if closing PowerShell doesn't fix the issue. A restart is the "nuclear option" that forces all processes to reload environment variables.
Q: Can I use a different shell like CMD or Git Bash?
A: Yes, but they also cache PATH. You'll need to close and reopen them too. The issue isn't PowerShell-specific — it's a Windows environment variable caching issue. All shells on Windows inherit PATH from the system and cache it.
Q: Is it worth switching to Linux to avoid this?
A: For OpenClaw development, yes. Linux comes with Node.js pre-installed and properly configured. No PATH issues, no shell restarts, no caching problems. Everything just works. Deploy on a VPS and save yourself the headache.
Related Fixes
-
Fix 'spawn npm ENOENT' on Windows - Plugin installation errors
-
Fix 'spawn EINVAL' on Windows - Permission issues
-
Fix Docker EACCES: Permission Denied - Docker permission issues
-
Running OpenClaw with DeepSeek R1: Complete Guide - Setup and configuration
Bottom Line: Windows PATH caching causes install.ps1 failures.
Close and reopen PowerShell for the quick fix. Restart your computer if that doesn't work.
Deploy on Vultr (High Availability & Free Credit) (Windows PATH issues are a headache. Linux just works.)
Still Stuck? Check Your Hardware
Sometimes the code is fine, but the GPU is simply refusing to cooperate. Before you waste another hour debugging, compare your specs against the Hardware Reality Table to see if you are fighting impossible physics.
Bookmark this site
New fixes are added as soon as they appear on GitHub Issues.
Browse Error Index →