Upgrade angular-cli to v6: Cannot read property 'prototype' of undefined
Versions
Angular CLI: 6.0.3 Node: 8.11.2 OS: win32 x64 Angular: 6.0.3 ... animations, cli, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.6.3 @angular-devkit/build-angular 0.6.3 @angular-devkit/build-optimizer 0.6.3 @angular-devkit/core 0.6.3 @angular-devkit/schematics 0.6.3 @angular/cdk 6.1.0 @angular/material 6.1.0 @ngtools/webpack 6.0.3 @schematics/angular 0.6.3 @schematics/update 0.6.3 rxjs 6.2.0 typescript 2.7.2 webpack 4.8.3 Windows 7
Repro steps
1.- Upgrade the application for using angular6 and rxjs6. I've based on https://update.angular.io/ tips. 2.- The application runs succesfully until I update from @angular/cli:1.7.4 to @angular/cli:6.0.3
Then I need to install: npm install stream events buffer asn1 timers vm --save to make the application compile. The application is served but when rendering the browser It shows:
index.js:43 Uncaught ReferenceError: global is not defined
at Object../node_modules/buffer/index.js (index.js:43)
I solve it via: (window as any).global = window;
Observed behavior
Then the browser shows:
Uncaught ReferenceError: global is not defined
at Object../node_modules/buffer/index.js (index.js:43)
at __webpack_require__ (bootstrap:76)
at Object../node_modules/safe-buffer/index.js (index.js:2)
at __webpack_require__ (bootstrap:76)
at Object../node_modules/randombytes/browser.js (browser.js:7)
at __webpack_require__ (bootstrap:76)
at Object../node_modules/crypto-browserify/index.js (index.js:3)
at __webpack_require__ (bootstrap:76)
at Object../src/app/auth/auth.service.ts (auth.module.ts:14)
Which I don't know how to solve.
"xml2js": "0.4.19",
"xml2js-es6-promise": "1.1.1",
Desired behavior
The login page would be rendered as used.
Mention any other details that might be useful (optional)
This are the imports on the service that throws the exception: `import { Injectable } from '@angular/core'; import { CommonModule } from '@angular/common'; import { Router } from '@angular/router'; import { Observable, Subject } from 'rxjs';
import * as crypto from 'crypto-browserify'; import * as xml2js from 'xml2js-es6-promise';`
And the package in use:
"jszip": "^3.1.5", "xml2js": "0.4.19", "xml2js-es6-promise": "1.1.1",
It seems that this bug is related with this one:
https://github.com/angular/angular-cli/issues/9827#issuecomment-369647555
Please, check the @filipesilva comment. Seems that jszip and xml2js uses 'global' and 'requires' sentences that are not supported anymore on Angular-cli@6...
@Pilukina yes you are correct that the comment you linked explains this situation. I am sorry that this change affects you, the reasoning there is explained there though.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.