Angular 5 - Uncaught ReferenceError: req is not defined

Viewed 2450

I recently updated my running project from Angular 4.4.3 to Angular5. I updated all angular packages to Angular 5.0.0 as per the update guide.

Plus I also updated the angular CLI to 1.5.0. Since then I am getting below error in console:

polyfills.b8a5e5b….bundle.js:1 Uncaught ReferenceError: req is not defined
    at polyfills.b8a5e5b….bundle.js:1
    at polyfills.b8a5e5b….bundle.js:1
    at polyfills.b8a5e5b….bundle.js:1
    at Function.r.__load_patch (polyfills.b8a5e5b….bundle.js:1)
    at polyfills.b8a5e5b….bundle.js:1
    at c (polyfills.b8a5e5b….bundle.js:1)
    at Object.<anonymous> (polyfills.b8a5e5b….bundle.js:1)
    at Object.eFQL (polyfills.b8a5e5b….bundle.js:1)
    at n (inline.904a54f….bundle.js:1)
    at Object.TU+8 (polyfills.b8a5e5b….bundle.js:1)

Am I missing something here?

4 Answers

It's actually just a bug with uglify-es. Update uglify-es on your project to >3.1.8 until it's fixed in the CLI. Got the answer from here

Remove node_modules and run npm install.

It works for me.

The point is your version of CLI has old uglify-es. You need CLI in version 1.4.9.

Works for me:

  1. Remove node_modules from main project.

  2. npm install afresh

  3. go to Ctrl+Windows -> %appdata% -> npm -> node_modules -> @angular

  4. Remove cli

  5. Install CLI afresh by npm install -g @angular/cli@1.4.9

  1. Clear npm cache (npm cache clear --force)
  2. Delete node_modules
  3. Re-install all packages (npm install)
  4. Install latest version of uglify-es (npm install uglify-es@latest)
  5. Install 1.6.0-beta.0 or greater version of @angular/cli (globally and locally if you have a local installation [npm install @angular/cli@1.6.0-beta.0])
  6. Ignore explosion of dependency issues primarily caused by npm packages still catching up with Angular 5
  7. No errors, be happy

It's possible that only step 5 is really needed, but I ran every one of these steps and it fixed the issue.

Related