Uncaught ReferenceError: req is not defined with [email protected]
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.
- Clone this repo: https://github.com/ngx-rocket/starter-kit
npm installnpm run start -- --prodorng 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]
@sandangel Taken straight from @bh86
Works but is super ugly.
the issue identified by @clydin in uglify-es seems to be marked as solved now https://github.com/mishoo/UglifyJS2/issues/2437
Yes. It looks like a fix is in place and should be in the next patch version of uglify (3.1.8).
I encountered this error too, in CLI version 1.5 and Angular 5.0
same here
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
Same here, got this after upgrading to @angular/cli to 1.5.0
upgrade to cli 1.6-beta.0 fix this
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.
I am also facing this since yesterday when I upgraded to cli1.5!
As stated by @clydin, reinstall node_modules and it should be fixed :)
@Dasiim Ok will try this. Thanks @clydin !
@VishalGulati please update if it works! Thanks!
Just tested after a rm -rf node_modules, I still got the error.
After remove node_modules same here, still falling
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
}
}
It worked here after removing node_modules. Am I missing something? The problem was happening before the new uglify-es
Solved! I removed node_modules folder AND package-lock.json and now it works!
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].
Working here.