Errors / JavaScript errors
Uncaught ReferenceError: process is not defined
Code written for a server ran in the visitor's browser, where that part does not exist.
The script, often the whole app bundle, stops on load: a blank page.
Why it happens
- A dependency reads
process.envand the bundler no longer fills it in: webpack 5 and Vite stopped adding Node's globals for the browser. - App code reading
process.env.SOMETHINGin Vite, where it isimport.meta.envinstead.
How to fix it
- In Vite, use
import.meta.env.VITE_…, ordefine: { "process.env": {} }for a library that only reads it. - In webpack 5,
DefinePluginfor the values that are read, orProvidePluginwith theprocess/browserpackage. - Check the library for a browser build before shimming it.
Whose problem it is
Usually the site's own code or settings.
Does your site have it?
Free, no account. We open your page and four more in a clean Chrome and list every error like this one, with the page and the click that caused it. How the free page check works.
Often seen with
- require is not definedA file written for a server's module system was sent to the browser as it is.
- x is not definedA script used a name nobody declared, usually because another script it depends on did not load first.