angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Uncaught ReferenceError: req is not defined with [email protected]

Open sinedied opened this issue 9 years ago • 62 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular CLI: 1.5.0
Node: 7.9.0
OS: darwin x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, tsc-wrapped

@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.9
@angular/material: 2.0.0-beta.12
@angular/service-worker: 1.0.0-beta.16
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.4.2
webpack: 3.8.1

Repro steps.

  1. Clone this repo: https://github.com/ngx-rocket/starter-kit
  2. npm install
  3. npm run start -- --prod or ng serve --prod

The log given by the failure.

Build is successful, but app is throwing an error that seems to be due to zone.js polyfill:

polyfills.5ae6b10132b7e8411589.bundle.js:1 Uncaught ReferenceError: req is not defined
    at polyfills.5ae6b10132b7e8411589.bundle.js:1
    at polyfills.5ae6b10132b7e8411589.bundle.js:1
    at polyfills.5ae6b10132b7e8411589.bundle.js:1
    at Function.r.__load_patch (polyfills.5ae6b10132b7e8411589.bundle.js:1)
    at polyfills.5ae6b10132b7e8411589.bundle.js:1
    at u (polyfills.5ae6b10132b7e8411589.bundle.js:1)
    at Object.<anonymous> (polyfills.5ae6b10132b7e8411589.bundle.js:1)
    at Object.eFQL (polyfills.5ae6b10132b7e8411589.bundle.js:1)
    at n (inline.f05f710f0631368b608c.bundle.js:1)
    at Object.TU+8 (polyfills.5ae6b10132b7e8411589.bundle.js:1)

Desired functionality.

App does not throw any error.

Mention any other details that might be useful.

Was working fine with [email protected]

sinedied avatar Nov 05 '17 15:11 sinedied

I am also getting this but not using cli directly just the new AngularCompilerPlugin. Seems the app still functions though.

MikaAK avatar Nov 05 '17 16:11 MikaAK

This is actually a bug in uglify-es and looks like the next version should have a fix. Relevant issue: https://github.com/mishoo/UglifyJS2/issues/2437

clydin avatar Nov 05 '17 20:11 clydin

Upgrading node.js to latest LTS version, re-installing [email protected] & upgrading typescript to 2.6.1 I got rid this anoying error after rebuild my project. Before this, I got unmeet peer dependency on typescript & other angular dependencies.

ericzon avatar Nov 05 '17 21:11 ericzon

I got the same error here when upgrading a Angular 4.XX project to use with Angular-CLI 1.5

paulogr avatar Nov 05 '17 22:11 paulogr

What's the workaround here? :)

lexcaraig avatar Nov 06 '17 03:11 lexcaraig

Same error when upgrade to Angular 5.0.0 and Angular-CLI 1.5

mrnetforge avatar Nov 06 '17 09:11 mrnetforge

I updated from the latest 5 RC to the final 5 version. After that I got this error and "Cannot read property 'subscribe' of undefined" for some routes which made it impossible to navigate to this routes.

Even downgrading to the latest 5RC did not work which might be happening because of some dependency which has no pinned version and the latest one is broken.

Only a downgrade to the latest Angular 4 did make it work again.

Btw: On Thursday I updated another project and there were no problems.

acuntex avatar Nov 06 '17 09:11 acuntex

I have the same problem

icjking avatar Nov 06 '17 09:11 icjking

Same here. Upgraded from 4.4 to 5

thomaspink avatar Nov 06 '17 09:11 thomaspink

same issue cli 1.5, angular 5

dimitriy-k avatar Nov 06 '17 10:11 dimitriy-k

Same here, using Angular 5 and CLI 1.5

bop10 avatar Nov 06 '17 12:11 bop10

Same!!!

Ismaestro avatar Nov 06 '17 12:11 Ismaestro

It seems to be an CLI problem, Angular 4.4.6 and CLI 1.5 got the error

Angular 4.4.6 and CLI 1.4.9 everything works fine

jonathanbruno avatar Nov 06 '17 12:11 jonathanbruno

I also get this error with Angular CLI 1.5.0 :/

aalbericio avatar Nov 06 '17 12:11 aalbericio

We did the following (ugliest) workaround, in index.html: <script> window.req = window.dep = null; </script>

bh86 avatar Nov 06 '17 12:11 bh86

Yeah, it's definitely a CLI error since reverting to 1.4.9 fixed the problem.

aalbericio avatar Nov 06 '17 13:11 aalbericio

@bh86 that works but waiting for an official fix

Ismaestro avatar Nov 06 '17 13:11 Ismaestro

Hoping it'd be fixed soon

Kalki5 avatar Nov 06 '17 13:11 Kalki5

Webpack’s uglifyjs plugin was updated in CLI 1.5 which replaced uglify-js with uglify-es. This currently has a bug in its collapse_var optimization which is the cause of the error.

clydin avatar Nov 06 '17 14:11 clydin

I want to know how my app will be affected by this bug because it seem still work correctly. And do we have a work around for this issue?

sandangel avatar Nov 06 '17 15:11 sandangel