Angular 18 'ng serve' fails: @rollup/rollup-win32-x64-msvc module missing - npm optional dependency issue?

I’m having trouble with my Angular 18 project. When I try to run ‘ng serve’, it keeps complaining about a missing module: @rollup/rollup-win32-x64-msvc. I think it might be related to an npm bug with optional dependencies.

Here’s my setup:

  • Node.js: v20.15.1
  • Angular: v18
  • npm: v10.7.0

I’ve already tried these fixes, but no luck:

  1. Removing node_modules and package-lock.json
  2. Clearing the npm cache
  3. Manually installing @rollup/rollup-win32-x64-msvc

Has anyone else run into this problem? Any ideas on how to fix it? I’m pretty stuck and would appreciate any help!

I’ve dealt with this exact issue in Angular 18. The root cause is often a mismatch between your system architecture and the prebuilt binaries. Here’s what worked for me:

First, try running ‘npm install --force’. This sometimes resolves dependency conflicts. If that doesn’t work, consider using a package manager like pnpm, which handles optional dependencies better than npm.

Another approach is to add an .npmrc file in your project root with the line ‘optional=false’. This tells npm to skip optional dependencies, which might bypass the problematic @rollup module.

Lastly, ensure your Node.js version is compatible with Angular 18. Sometimes, rolling back to an earlier LTS version of Node can resolve these cryptic errors. Good luck troubleshooting!

I encountered a similar issue with Angular 18 when a missing @rollup/roll32-x64-msvc module was reported. After troubleshooting, I found that the problem was related to npm’s handling of optional dependencies. I resolved the issue by switching to yarn. After uninstalling npm globally and installing yarn instead, I deleted the node_modules folder and package-lock.json, ran yarn install in the project directory, and used yarn ng serve to start the development server. This approach solved the error. Alternatively, updating npm or using the --legacy-peer-deps flag might help. Also, check that your TypeScript version is compatible with Angular 18 as version mismatches can lead to issues.

hey jack, i’ve run into this too. what worked for me was using npm config set optionalDependencies false before running npm install. this skips those pesky optional deps that can cause issues. also, make sure ur using the right node version for angular 18. if all else fails, try nvm to switch node versions. good luck mate!