-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
-
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 (npm/cli#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/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.
Beta Was this translation helpful? Give feedback.
All reactions
check the NPMRC Config List
i follow the 2nd fix and it help me
https://raddy.dev/blog/how-to-fix-error-cannot-find-module-lightningcss-win32-x64-msvc-node/
npm config list
If you get OS = "linux" you have a problem with your configuration.
This will also give you the location of your .npmrc file. In my case it’s located under C:\Users\range.npmrc
How to fix it
-
Open the .npmrc file located at: C:\Users"your pc user name".npmrc
-
Change the OS from linux to win32
os = "win32" -
Save the file.
Replies: 2 comments 1 reply
-
check the NPMRC Config List
i follow the 2nd fix and it help me
https://raddy.dev/blog/how-to-fix-error-cannot-find-module-lightningcss-win32-x64-msvc-node/
npm config list
If you get OS = "linux" you have a problem with your configuration.
This will also give you the location of your .npmrc file. In my case it’s located under C:\Users\range.npmrc
How to fix it
-
Open the .npmrc file located at: C:\Users"your pc user name".npmrc
-
Change the OS from linux to win32
os = "win32" -
Save the file.
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 2
-
YOU SAVED MY LIFE and my mental sanity.
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 2
-
Thanks @rodri595 this solved my issue.
Annoyingly, mine was set to windows, changing it to win32 fixed the error.
The error appeared with a Vite version update (not sure which) on a React-Router project.
Beta Was this translation helpful? Give feedback.
All reactions
-
😄 1