clo5ure
clo5ure

Reputation: 90

Angular 8 Upgrade - ng build command gives @angular/platform-browser errors

I'm currently in the process of upgrading an Angular 7 app to Angular 8 and I'm running into some issues - I've previously upgraded from Angular 5 and 6 relatively smoothly so I have some experience with the process using Angular's upgrade guide.

I've followed all of the steps and have successfully upgraded all of my Angular dependencies to 8.1.x. I'm now using the { static: false } with ViewChild and my imports for Angular Material are up to date using deeper imports.

The issue arises when I attempt to build my application using ng build --aot --prod --build-optimizer=false. With this I get the following error.

chunk {0} runtime.e9d4a8365190f9ee7214.js (runtime) 2.21 kB [entry] [rendered]
chunk {1} main.82103d8cb2976079a759.js (main) 6.52 MB [initial] [rendered]
chunk {2} pdfjsWorker.4df5ce1f8ece90d58a9f.js (pdfjsWorker) 741 kB  [rendered]
chunk {3} polyfills.884b7d233bf412d2ec81.js (polyfills) 63.7 kB [initial] [rendered]
chunk {4} polyfills-es5.fb30af840b34e7fa0bb5.js (polyfills-es5) 69.8 kB [initial] [rendered]
chunk {5} styles.169e0b9ec596a5a72c8f.css (styles) 66.5 kB [initial] [rendered]
Date: 2019-07-26T00:55:16.623Z - Hash: 142d65823e318484d40b - Time: 68210ms

ERROR in ./src/app/app.module.ngfactory.js 318:10580-10593
"export 'DOCUMENT' (imported as 'i129') was not found in '@angular/platform-browser'
ERROR in ./node_modules/ng-intercom/fesm5/ng-intercom.js 501:83-91
"export 'DOCUMENT' was not found in '@angular/platform-browser'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `npx ng build --aot --prod --build-optimizer=false && npx tsc -p tsconfig.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I'm not really sure what's going on here with the whole export DOCUMENT issue.

Here's what I get when I run ng --version.

Angular CLI: 8.1.2
Node: 10.15.3
OS: darwin x64
Angular: 8.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.801.2
@angular-devkit/build-angular      0.801.2
@angular-devkit/build-optimizer    0.801.2
@angular-devkit/build-webpack      0.801.2
@angular-devkit/core               8.1.2
@angular-devkit/schematics         8.1.2
@angular/cdk                       8.1.1
@angular/http                      7.2.15
@angular/material                  8.1.1
@angular/material-moment-adapter   8.1.1
@ngtools/webpack                   8.1.2
@schematics/angular                8.1.2
@schematics/update                 0.801.2
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.35.2

Upvotes: 0

Views: 660

Answers (2)

Ashh640
Ashh640

Reputation: 124

Looks like the dependency ng-intercom is importing DOCUMENT from platform-browser, whereas it should now be imported from '@angular/common'.

Try seeing if there is a new version of ng-intercom that supports a more recent version of Angular, then try running ng update again.

Upvotes: 1

Chanaka Weerasinghe
Chanaka Weerasinghe

Reputation: 5742

Document is no longer in @angular/platform-browser It is located in @angular/common

import { DOCUMENT } from '@angular/common'<----replace;

Reference https://angular.io/api/common/DOCUMENT

Upvotes: 1

Related Questions