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

@sandangel Taken straight from @bh86

Works but is super ugly.

SargoDarya avatar Nov 06 '17 15:11 SargoDarya

the issue identified by @clydin in uglify-es seems to be marked as solved now https://github.com/mishoo/UglifyJS2/issues/2437

peterpeterparker avatar Nov 06 '17 15:11 peterpeterparker

Yes. It looks like a fix is in place and should be in the next patch version of uglify (3.1.8).

clydin avatar Nov 06 '17 15:11 clydin

I encountered this error too, in CLI version 1.5 and Angular 5.0

svenheden avatar Nov 06 '17 18:11 svenheden

same here

stewones avatar Nov 06 '17 21:11 stewones

Just for completeness, a production build with sourcemaps enabled shows the following stacktrace:

zone.js:2620 ▼ Uncaught ReferenceError: req is not defined
    at zone.js:2620
    at zone.js:2543
    at zone.js:2867
    at Function.r.__load_patch (zone.js:86)
    at zone.js:2866
    at c (zone.js:9)
    at Object.<anonymous> (zone.js:8)
    at Object.eFQL (zone.js:3014)
    at n (bootstrap 62f4ccd68d66309f4fdd:54)
    at Object.TU+8 (polyfills.ts:56)
(anonymous) @ zone.js:2620
(anonymous) @ zone.js:2543
(anonymous) @ zone.js:2867
r.__load_patch @ zone.js:86
(anonymous) @ zone.js:2866
c @ zone.js:9
(anonymous) @ zone.js:8
eFQL @ zone.js:3014
n @ bootstrap 62f4ccd68d66309f4fdd:54
TU+8 @ polyfills.ts:56
n @ bootstrap 62f4ccd68d66309f4fdd:54
1 @ reflect.js:15
n @ bootstrap 62f4ccd68d66309f4fdd:54
window.webpackJsonp @ bootstrap 62f4ccd68d66309f4fdd:25
(anonymous) @ polyfills.bundle.js:1

GiuseppePiscopo avatar Nov 06 '17 23:11 GiuseppePiscopo

Same here, got this after upgrading to @angular/cli to 1.5.0

mediantiba avatar Nov 07 '17 03:11 mediantiba

upgrade to cli 1.6-beta.0 fix this

sandangel avatar Nov 07 '17 04:11 sandangel

uglify-es 3.1.8 is out with the fix. There’s no need to update the CLI just ensure that version 3.1.8 or greater of uglify-es is installed.

clydin avatar Nov 07 '17 05:11 clydin

I am also facing this since yesterday when I upgraded to cli1.5!

VishalGulati avatar Nov 07 '17 05:11 VishalGulati

As stated by @clydin, reinstall node_modules and it should be fixed :)

Dasiim avatar Nov 07 '17 05:11 Dasiim

@Dasiim Ok will try this. Thanks @clydin !

VishalGulati avatar Nov 07 '17 06:11 VishalGulati

@VishalGulati please update if it works! Thanks!

lexcaraig avatar Nov 07 '17 06:11 lexcaraig

Just tested after a rm -rf node_modules, I still got the error.

sinedied avatar Nov 07 '17 08:11 sinedied

After remove node_modules same here, still falling

Ismaestro avatar Nov 07 '17 08:11 Ismaestro

It's a problem with uglify. If you have an ejected webpack config add this to your uglify plugin else it's a wait for the update it seems

uglifyOptions: {
  compress: {
    collapse_vars: false
  }
}

MikaAK avatar Nov 07 '17 09:11 MikaAK

It worked here after removing node_modules. Am I missing something? The problem was happening before the new uglify-es

leandrogaspar avatar Nov 07 '17 09:11 leandrogaspar

Solved! I removed node_modules folder AND package-lock.json and now it works!

Ismaestro avatar Nov 07 '17 09:11 Ismaestro

rm -rf node_modules
rm package-lock.json
npm cache clean --force
npm install
ng serve --prod

Still not working with angular@5 / [email protected].

sinedied avatar Nov 07 '17 11:11 sinedied

Working here.

Ismaestro avatar Nov 07 '17 11:11 Ismaestro