#20332Cannot find the module @rollup/rollup-win32-x64-msvc
Issue Details
Describe the bug
When I create a React or Angular project using Vite and try to run it, I encounter the following error:
Error: Cannot find module '@rollup/rollup-win32-x64-msvc' It seems to be related to a known npm bug involving optional dependencies.
I downgraded to Vite 4.4.0, and the projects run without issues.
This problem occurs only on Windows 11. I tested the same setup on a Linux VM, and everything works fine there.
Reproduction
.
Steps to reproduce
vite-project@0.0.0 dev vite
C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js:64 throw new Error( ^
Error: Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i
again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js:64:9)
at Object. (C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js:73:76)
at Module._compile (node:internal/modules/cjs/loader:1730:14)
at Object..js (node:internal/modules/cjs/loader:1895:10)
at Module.load (node:internal/modules/cjs/loader:1465:32)
at Function._load (node:internal/modules/cjs/loader:1282:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at cjsLoader (node:internal/modules/esm/translators:266:5)
at ModuleWrap. (node:internal/modules/esm/translators:200:7) {
[cause]: Error: Cannot find module '@rollup/rollup-win32-x64-msvc'
Require stack:
- C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22) at Function._load (node:internal/modules/cjs/loader:1211:37) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Module.require (node:internal/modules/cjs/loader:1487:12) at require (node:internal/modules/helpers:135:16) at requireWithFriendlyError (C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js:46:10) at Object. (C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js:73:76) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\Ishak\OneDrive\Desktop\vite-project\node_modules\rollup\dist\native.js' ] } }
Node.js v22.17.0
System Info
System: OS: Windows 11 10.0.26100 CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U Memory: 7.99 GB / 15.73 GB Binaries: Node: 22.17.0 - C:\nvm4w\nodejs\node.EXE npm: 11.4.2 - C:\nvm4w\nodejs\npm.CMD Browsers: Edge: Chromium (136.0.3240.92) npmPackages: [@vitejs](https://github.com/vitejs)/plugin-react: ^4.5.2 => 4.6.0 vite: ^7.0.0 => 7.0.0
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.