Vite will not start because Rollup's native package is missing
Error: Cannot find module @rollup/rollup-win32-x64-msvcShort answer
Rollup ships its compiler as a separate package for each OS and CPU. npm installs only the one that matches the machine, and a package-lock.json or node_modules folder made on another system can leave it out. Delete both, run npm install again, and check the Visual C++ runtime if the message mentions a missing DLL.
Fix it fast
1Find out which cause you have
Read the first two lines of the error. 'Cannot find module' with the npm bug note means the platform package was never installed. 'Required DLL was not found' means it is installed but Windows cannot load it.
node -p "process.platform + ' ' + process.arch" npm ls @rollup/rollup-win32-x64-msvc2Match what you see, then jump to its fix
- 1
Cannot find module @rollup/rollup-<platform>, followed by the note about the npm bugnode_modules or the lockfile came from a different OS or CPUFix - 2
Required DLL was not found. This error usually happens when Microsoft Visual C++ Redistributable is not installed.The Visual C++ Redistributable is missing on WindowsFix - 3
Works on the machine that made the lockfile; fails in CI or on a teammate's computer with the same npm bug noteA lockfile created by npm kept only one platform's optional packagesFix
- 1
What does the error look like?
Error: Cannot find module @rollup/rollup-win32-x64-msvcnpm 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.Required DLL was not found. This error usually happens when Microsoft Visual C++ Redistributable is not installed.
Cause 1 of 3
node_modules or the lockfile came from a different OS or CPU
1Check
Rollup keeps its native code in packages named after the platform, such as @rollup/rollup-win32-x64-msvc. They are optional dependencies, so npm installs only the one that fits the current machine. A node_modules folder copied from another system, or a lockfile regenerated on one, can be missing the package you need now. The command prints which Rollup packages are present.
ls node_modules/@rollup
grep -c "@rollup/rollup-" package-lock.json2Fix
Do what Rollup's own message says: remove both the lockfile and node_modules, then install again on the machine that will run the build. Commit the new lockfile after that.
rm -rf node_modules package-lock.json
npm install3Verify
The package for this platform is listed, and Vite starts.
ls node_modules/@rollup
npx vite --versionConfirmed by raw.githubusercontent.com
Cause 2 of 3
The Visual C++ Redistributable is missing on Windows
1Check
Rollup throws this variant on Windows when the native file exists but Node.js fails to load it with ERR_DLOPEN_FAILED because a dependent DLL cannot be found. Reinstalling node_modules does not help here.
node -p "process.arch"2Fix
Install the Microsoft Visual C++ Redistributable that matches the architecture printed above (x64, x86 or arm64). Rollup's error prints the download link, which starts with https://aka.ms/vs/17/release/.
# x64 example: download and run
# https://aka.ms/vs/17/release/vc_redist.x64.exe3Verify
Open a new terminal and start Vite again.
npx vite --versionConfirmed by raw.githubusercontent.com
Cause 3 of 3
A lockfile created by npm kept only one platform's optional packages
1Check
npm issue 4828 reports that when node_modules already holds one platform's optional package, npm can write a lockfile that lists only that platform. Other systems then skip theirs without a warning.
grep -n "@rollup/rollup-" package-lock.json2Fix
Regenerate the lockfile from scratch as in the first cause, then reinstall in CI with the same npm major version you use locally.
rm -rf node_modules package-lock.json
npm install
npm ci3Verify
npm ci finishes and the build runs on the other platform.
npm run buildConfirmed by github.com
How do I stop it coming back?
- Never copy node_modules between operating systems or into a Docker image from the host; run npm install or npm ci inside the target environment.
- Keep node_modules and dist in .gitignore and in .dockerignore.
- Use the same Node.js and npm versions locally and in CI.
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
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fix