question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

external "require('url')":1 Uncaught ReferenceError: require is not defined

See original GitHub issue

@maximegris When i run npm run start:web to serve the app from the browser i am getting following error. It looks like chrome does not know how to interpret require('url') which is node module. the only place i can find this import is in webpack externals. Can you please point me into right direction?

external "require('url')":1 Uncaught ReferenceError: require is not defined
    at Object.<anonymous> (external "require('url')":1)
    at __webpack_require__ (bootstrap 151bbb78dee4aab80101:54)
    at Object.<anonymous> (client:2)
    at Object.<anonymous> (client?ffdb:204)
    at __webpack_require__ (bootstrap 151bbb78dee4aab80101:54)
    at Object.<anonymous> (polyfills.bundle.js:5881)
    at __webpack_require__ (bootstrap 151bbb78dee4aab80101:54)
    at webpackJsonpCallback (bootstrap 151bbb78dee4aab80101:25)
    at polyfills.bundle.js:1
14:57:33.753 core.es5.js:350 Uncaught reflect-metadata shim is required when using class decorators

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:22 (5 by maintainers)

github_iconTop GitHub Comments

19reactions
whyboriscommented, May 9, 2019

I had this problem happen recently when upgrading from Electron 4 to Electron 5.

Solution: https://stackoverflow.com/questions/55093700/electron-5-0-0-uncaught-referenceerror-require-is-not-defined

It turns out, nodeIntegration was true by default in previous electron versions, but false by default in 5.0.0.

Setting nodeIntegration to true may fix your upgrade from Electron 4 to 5:

new BrowserWindow({
    webPreferences: {
      nodeIntegration: true,
6reactions
thomascaynecommented, Feb 15, 2020

@maximegris Great project. Thank you. This is my 3rd project with it.

I just cloned angular-electron to start a new project (3rd). The same error with require came up with npm start for only http://localhost:4200/ (as in my 2nd project which I never spent time to figure out. Now I did). npm start invokes both web & electron app. Which is the ideal scenario.

Also, running ng:serve produces the require error for only http://localhost:4200/.

The solution:

  • Do not use ng:serve
  • Do use: ng:serve:web

or change npm start to:

"start": "npm-run-all -p ng:serve:web electron:serve"

I suggest removing reference to ng:serve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Once I set nodeIntegration:false -> "Uncaught ReferenceError ...
Once I set nodeIntegration:false -> "Uncaught ReferenceError: require is not defined at Object.url (external "url":1) " #electron-#react-# ...
Read more >
ReferenceError: require is not defined in JavaScript - Stack Diary
The "ReferenceError: require is not defined" error occurs when the require function is used in a JavaScript file that is intended to be ......
Read more >
How To Fix ReferenceError require is not defined in JavaScript
The Solution. Your ReferenceError: require is not defined likely has one of two causes: You tried using require in a browser environment ......
Read more >
How to fix the error `require is not defined` in Node.js
Today I started writing a new project on Node.js and got this error on the very first run: const express = require('express'); ...
Read more >
Once I set nodeIntegration: false, I get this error: external "url"
external "url":1 Uncaught ReferenceError: require is not defined at Object.url (external "url":1) at __webpack_require__ (bootstrap:789) at fn ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found