npm run dev cannot find Vite: Cannot find module vite\bin\vite.js
Error: Cannot find module 'C:\foo\bar&baz\vite\bin\vite.js'Short answer
The dev script runs the vite binary from node_modules. If you never ran npm install, or Vite is not in devDependencies, that binary does not exist. On Windows, an & in the folder path also breaks npm. Install Vite as a dev dependency, or move the project to a path without &.
Fix it fast
1Find out which cause you have
Check that Vite is listed and that its binary exists in this project.
npm ls vite ls node_modules/.bin/vite2Match what you see, then jump to its fix
What does the error look like?
Error: Cannot find module 'C:\foo\bar&baz\vite\bin\vite.js'
Cause 1 of 2
Dependencies were never installed, or Vite is missing from package.json
1Check
A fresh clone has no node_modules. Also confirm the scripts section runs plain vite.
grep -n -A4 '"scripts"' package.json2Fix
Install the dependencies. If Vite is not listed at all, add it as a dev dependency, and use the standard scripts.
npm install
npm install -D vite3Verify
Start the server. Vite serves at http://localhost:5173 by default.
npx viteConfirmed by vite.dev
Cause 2 of 2
The project path contains an ampersand on Windows
1Check
npm on Windows breaks when a folder name has an & in it.
cd2Fix
Rename or move the project to a path without &, or use pnpm or Yarn.
move "C:\foo\bar&baz" "C:\foo\barbaz"3Verify
Run the dev script from the new path.
npm run devConfirmed by vite.dev
How do I stop it coming back?
- Run npm install (or npm ci in CI) after every clone and every branch change that touches package.json.
- Keep project folder names free of an ampersand.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
Vite cannot read your vite.config file
Cannot find module
Vite loads vite.config as a file in its own right, and it must be detected as ESM by Node.js if it uses import and export.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix