Errors / JavaScript errors
Uncaught ReferenceError: require is not defined
A file written for a server's module system was sent to the browser as it is.
The script does not run at all.
Why it happens
- A CommonJS file (
require(…),module.exports) loaded with a plain<script>tag, with no bundler in between. - A build that marks a dependency as external, so its
requirecall reaches the browser. - Electron or Node code reused in a web page.
How to fix it
- Bundle it (Vite, webpack, esbuild), or use the library's browser or ESM build.
- In a
<script type="module">, useimportinstead. - In DevTools' Sources panel the file will show
require(near the top, unbundled; in the Network panel it is often served straight fromnode_modulesor asrc/folder rather than a build directory. That is the sign the deploy shipped source files, not the build output.
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
- Cannot use import statement outside a moduleA modern script was loaded the old way, so the browser refused to read it.
- process is not definedCode written for a server ran in the visitor's browser, where that part does not exist.