npm install prerender fails with "Failed to locate: CL.exe" on Windows: what it means and the fix
You ran npm install for prerender on Windows, and the build stopped at "Failed to locate: CL.exe". CL.exe is Microsoft's C++ compiler, and the install couldn't find it. The fix is to install the Visual C++ build tools, then run npm install again from a Developer Command Prompt. And if all you wanted was the middleware for your app, check first whether you need this build at all.
Microsoft's docs describe cl.exe plainly: "Use the compiler (cl.exe) to compile and link source code files into apps, libraries, and DLLs." node-gyp, per its README, is "a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js." No compiler on the machine, no build.
Check which prerender package you actually need
This one is easy to miss. prerender-node describes itself as "Express middleware for prerendering javascript-rendered pages on the fly for SEO". That's the piece that goes in your app.
The prerender-node README says: "We host a Prerender server at prerender.io so that you can work on more important things." It also says the middleware "will default to the service already deployed by prerender.io". You can point it at a different service with the PRERENDER_SERVICE_URL environment variable or the prerenderServiceUrl option.
So if your goal is "my React or Vue site should serve HTML to crawlers through a hosted service", the package to install in your app is the middleware:
npm install prerender-node --saveThere's one catch. The same README says: "If you're testing locally, you'll need to run the prerender server locally so that it has access to your server." If that's your case, or you want to run the server yourself, keep reading and fix the compiler.
If you'd rather not run the server at all, here's one option. We make RenderSwap, a hosted prerender service: your prerender-node middleware stays, and you swap the service URL and the token for the ones from your RenderSwap account. The Free plan covers 1 verified domain and 500 fresh renders or 1 browser hour a month, whichever comes first, with no card and no email to sign up. It renders only your own public pages, on domains you've verified, so it won't help with a localhost test.
Install the Visual C++ build tools
node-gyp's own README covers this. The quick route uses Chocolatey and installs Python and the Visual C++ workload in one go:
choco install python visualstudio2026-workload-vctools -yFor the manual route, the README says that for Visual Studio 2019 or later, you use the `Desktop development with C++` workload. For anything older, it says to install Visual Studio Build Tools with the Visual C++ build tools option. Microsoft's page adds that if you want only the command-line toolset, you can download the Build Tools for Visual Studio.
- Already have Visual Studio 2019 or later? Add the Desktop development with C++ workload to it.
- Fresh machine, no Visual Studio? Use the Chocolatey line above, or Build Tools for Visual Studio if you want only the command-line toolset.
- Installing Node.js anyway? The windows-build-tools project notes that "the official Node.js for Windows installer can now automatically install the required tools." Look for that while you run the installer.
- On Windows on ARM? node-gyp says to add the components "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".
If you've seen advice to install windows-build-tools, check its repository page first. It now says: "This repository was archived by the owner on Sep 11, 2021. It is now read-only." Use the routes above instead.
Run npm install from a Developer Command Prompt
Installing the tools isn't always the end of it. Microsoft's page says: "The tools require several environment variables to be set. These variables add the tools to the path and set the locations of include files, library files, and SDKs."
- Close every terminal, including your editor's built-in one.
- Open the Developer Command Prompt for your version of Visual Studio. Microsoft's page says to type developer command prompt in the desktop search box, then choose the result you want.
- Change to your project folder and run npm install again.
- Don't copy the compiler folders into your system PATH by hand. Microsoft's page says: "We don't recommend you set these variables in the Windows environment yourself."
If the install now gets past the compile step, you're done. If it fails with a different error, read the first error line in the log, not the last one.
When node-gyp still can't find Visual Studio
If the tools are installed and node-gyp still doesn't pick them up, the README suggests installing a PowerShell module:
Install-Module VSSetup -Scope CurrentUserIn the README's words: "This will make Visual Studio detection logic use a more flexible and accessible method, avoiding PowerShell's `ConstrainedLanguage` mode."
You can also tell node-gyp which Visual Studio to use. Its --msvs_version option is described as "Set Visual Studio version (Windows only)". For one older toolset you need it: "Auto-detection fails for Visual C++ Build Tools 2015, so `--msvs_version=2015`" needs to be added. The README notes it's not needed when run by npm as configured in its install steps.
node-gyp configure --msvs_version=2015Quick reference: which fix for which setup
| Your situation | What to do |
|---|---|
| You only need the middleware in your Express app | Install prerender-node and point it at a hosted service |
| You want to run the prerender server yourself | Install the Desktop development with C++ workload or Build Tools for Visual Studio |
| Tools installed, error still there | Re-run npm install from a fresh Developer Command Prompt |
| node-gyp can't detect Visual Studio | Install the VSSetup PowerShell module, or pass --msvs_version |
| Windows on ARM | Add the ARM64 compiler and ATL components |
Sources
- node-gyp README: installing on Windows
- Microsoft guide to the MSVC toolset on the command line
- prerender-node middleware setup guide
- windows-build-tools archived repository page
Questions
Do I need the full Visual Studio IDE to fix "Failed to locate: CL.exe"?
No. Microsoft says that if you want only the command-line toolset, you can download the Build Tools for Visual Studio. node-gyp's README also gives a Chocolatey command that installs Python and the Visual C++ workload.
I installed the C++ tools and still get the error. Why?
Check your terminal first. Microsoft says the tools require several environment variables, and these variables add the tools to the path. Open a new Developer Command Prompt and run npm install again from there.
Is windows-build-tools still the way to install the compiler?
Its repository was archived by the owner on Sep 11, 2021 and is read-only. The same page says the official Node.js for Windows installer can now install the required tools, and node-gyp's README lists the Visual Studio routes.
Do I need the prerender package to use prerender-node with a hosted service?
Not going by the prerender-node README. prerender-node is the Express middleware, and it defaults to the service already deployed by prerender.io. You can set PRERENDER_SERVICE_URL or prerenderServiceUrl to use a different service. The README says that if you're testing locally, you'll need to run the prerender server locally so that it has access to your server.