Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Vite will not start because Rollup's native package is missing

ErrorError: Cannot find module @rollup/rollup-win32-x64-msvc

Short 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.

  • Applies to Vite 7, Rollup 4, Node.js 22, npm 10
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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-msvc
  2. 2Match what you see, then jump to its fix

    1. 1Cannot 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. 2Required 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. 3Works 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

What does the error look like?

  • 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.
  • 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.json

2Fix

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 install

3Verify

The package for this platform is listed, and Vite starts.

ls node_modules/@rollup
npx vite --version

Confirmed by raw.githubusercontent.com

Did this fix it?

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.exe

3Verify

Open a new terminal and start Vite again.

npx vite --version

Confirmed by raw.githubusercontent.com

Did this fix it?

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.json

2Fix

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 ci

3Verify

npm ci finishes and the build runs on the other platform.

npm run build

Confirmed by github.com

Did this fix it?

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.