How to Fix Vite Project Creation Issues Caused by Chocolatey Node.js Installation
I tried to create a new Vite project on Windows and got this error:
npm create vite@latest
npm ERR! could not determine executable to runnpm ERR! A complete log of this run can be found in:npm ERR! C:\Users\[username]\AppData\Local\npm-cache\_logs\[timestamp]-debug-0.logAfter three hours of debugging, I discovered the culprit: Chocolatey. The Node.js installer had silently installed a Chocolatey-managed version of Node.js alongside the official one, creating PATH conflicts that broke npm and npx.
The Root Cause
I had installed Node.js using the official Windows installer from nodejs.org. Everything seemed fine at first. But when I tried running npm create vite@latest, the command would either fail silently or produce cryptic errors about missing executables.
The issue? During the Node.js installation, I had left the default options checked. One of those defaults automatically installs Chocolatey and uses it to manage the Node.js installation. This creates a situation where you have two competing Node.js installations:
- The official Node.js installation
- A Chocolatey-managed Node.js installation
The PATH environment variable gets confused about which npm and npx to use, leading to inconsistent behavior.
Verifying the Problem
First, I checked which Node.js installations existed on my system:
where.exe nodeThe output revealed the problem:
C:\Program Files\nodejs\node.exeC:\ProgramData\chocolatey\bin\node.exeTwo different Node.js installations. The Chocolatey one was interfering with the official installation.
I also checked npm and npx:
where.exe npmwhere.exe npxBoth commands returned mixed paths pointing to different installations. This mismatch between where node, npm, and npx lived was causing the npm create vite@latest command to fail.
The Fix: Clean Reinstallation
The solution was to completely remove Node.js and reinstall it without Chocolatey involvement.
Step 1: Uninstall via the Node.js Installer
I downloaded the official Node.js installer from nodejs.org again. Running it with an existing installation presents a maintenance mode dialog:
- Run the Node.js installer (the same .msi file you used before)
- Select “Remove” when prompted
- Complete the removal process
But here is the catch: running the uninstaller once might not catch everything, especially if Chocolatey installed its own instance.
Step 2: Remove Chocolatey’s Node.js
I needed to check if Chocolatey still had Node.js installed:
choco list --local-onlyIf you see nodejs or nodejs-lts in that list, remove it:
choco uninstall nodejsI also manually removed any remaining Node.js directories:
Remove-Item -Recurse -Force "C:\Program Files\nodejs"Remove-Item -Recurse -Force "C:\ProgramData\chocolatey\lib\nodejs"Step 3: Clean PATH and Environment Variables
After removal, I checked the system PATH to ensure no stale references remained:
$env:PATH -split ';' | Where-Object { $_ -match 'nodejs|chocolatey' }If any orphaned paths remain, you need to remove them manually:
- Open System Properties (Win + R, type
sysdm.cpl) - Go to Advanced > Environment Variables
- Edit both User and System PATH variables
- Remove any paths containing
nodejsorchocolateythat look orphaned
Step 4: Reinstall Node.js (The Right Way)
Now for the critical part. I ran the Node.js installer again, but this time I paid close attention to the options:
- Download the Windows Installer (.msi) from nodejs.org
- Run the installer
- Accept the license agreement
- On the “Custom Setup” page, click each feature and examine the options
- Look for any checkbox that mentions “Automatically install Chocolatey” or similar
- Uncheck that option
The exact location of this checkbox varies between Node.js versions, but it is typically on the “Custom Setup” or “Additional Tasks” page of the installer wizard.
Step 5: Verify the Clean Installation
After installation, I verified everything worked:
node -vnpm -vBoth commands returned version numbers without errors.
Then I checked that only one Node.js installation existed:
where.exe nodeThis time, the output showed only one path:
C:\Program Files\nodejs\node.exePerfect. A clean, single installation.
Step 6: Test Vite Project Creation
Finally, I tested the original command that failed:
npm create vite@latest my-projectcd my-projectnpm installnpm run devThe project created successfully, and the dev server started without issues.
Why This Happens
The Node.js installer includes an option to use Chocolatey for package management. When checked, it installs Chocolatey and registers Node.js as a Chocolatey package. This creates two parallel installations:
- The installer copies Node.js to
C:\Program Files\nodejs\ - Chocolatey creates symlinks or copies to
C:\ProgramData\chocolatey\bin\
Both get added to PATH. When you run npm or npx, Windows finds the first match, but the executables might be from different installations. This breaks commands like npm create that rely on npx being properly integrated with npm.
Alternative Solutions
While the official installer approach worked for me, there are other ways to avoid this issue entirely:
Use a Version Manager
Tools like mise (formerly rtx) or nvm-windows manage Node.js versions without system-wide PATH modifications:
mise install node@22mise use node@22This approach keeps Node.js isolated and makes version switching painless.
Use WSL
The top comment on my Reddit thread suggested using Windows Subsystem for Linux (WSL). WSL provides a proper Linux development environment without Windows PATH quirks:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -sudo apt-get install -y nodejsThis eliminates Chocolatey conflicts entirely since Chocolatey does not run on Linux.
Lessons Learned
- Always review installer options: Default checkboxes are not always optimal for development environments
- Verify installations: Run
where.exe nodeafter installing to catch duplicate installations early - One package manager at a time: Mixing Chocolatey, Scoop, and official installers on the same machine creates conflicts
- Test critical commands: After installing Node.js, immediately test
npm -v,npx -v, andnpm create vite@latestto catch issues before they waste hours
The fix itself took ten minutes once I understood the problem. The three hours I lost came from not realizing that the Node.js installer had added Chocolatey without my explicit knowledge.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments