Skip to content

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 require call reaches the browser.
  • Electron or Node code reused in a web page.

How to fix it

  1. Bundle it (Vite, webpack, esbuild), or use the library's browser or ESM build.
  2. In a <script type="module">, use import instead.
  3. In DevTools' Sources panel the file will show require( near the top, unbundled; in the Network panel it is often served straight from node_modules or a src/ 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.

Check only sites you run or have permission to check.

Often seen with