"export 'DOCUMENT' was not found in '@

2020-02-09 09:59发布

Happened while trying to upgrade IONIC app from version 3 to 4

Updated all plugins and modules to latest available, without any luck.

ERROR in ./node_modules/ionic-angular/components/app/app.js 24:35-43
"export 'DOCUMENT' was not found in '@angular/platform-browser'
ERROR in ./node_modules/ionic-angular/module.js 195:71-79
"export 'DOCUMENT' was not found in '@angular/platform-browser'
[ERROR] An error occurred while running subprocess ng.

This is my IONIC INFO

Ionic info:
Ionic:

   Ionic CLI                     : 5.1.0 (C:\Users\Acer\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.6.0
   @angular-devkit/build-angular : 0.800.6
   @angular-devkit/schematics    : 8.0.6
   @angular/cli                  : 8.0.6
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res : 0.5.1
   native-run  : 0.2.6

System:

   Android SDK Tools : 26.1.1 (C:\Users\Acer\AppData\Local\Android\sdk)
   NodeJS            : v10.11.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.2
   OS                : Windows 10

would appreciate, somebody could be helpful.

3条回答
闹够了就滚
2楼-- · 2020-02-09 10:10

DOCUMENT is removed from @angular/platform-browser If you use DOCUMENT from @angular/platform-browser, you should start to import this from @angular/common.

until the repo gets it fixed, you can do as below to fix it for you...

IN

\node_modules\ionic-angular\components\app\app.js

Replace

import { DOCUMENT, Title } from '@angular/platform-browser';

with

import { DOCUMENT } from '@angular/common';
import { Title } from '@angular/platform-browser';

And IN

\node_modules\ionic-angular\module.js

Replace

import { DOCUMENT, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';

With

import { DOCUMENT } from '@angular/common';
import { HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
查看更多
叼着烟拽天下
3楼-- · 2020-02-09 10:27

inside this "\node_modules\ionic-angular\module.js" && app.js file we can't change if we are changing manuvally it dosent take;

so i suggest BehaviorSubject of angular functionality we can get componet changing values in any other component

page.ts // component

import { BehaviorSubject } from 'rxjs';

public status = new BehaviorSubject('');
  currentStatus = this.status.asObservable()

; // write this code inside the export class services

changeStatus(status){
  console.log('current status from common services:',status)
  this.status.next(status); // pass value to public observable variable
  }

you can subscribe response in other componet

查看更多
Root(大扎)
4楼-- · 2020-02-09 10:30

It appears that you may be trying to upgrade your Ionic project from v3 to v4 inline rather than creating a new v4 project and migrating your old code over.

See the migration guide: https://ionicframework.com/docs/building/migration. Specifically this advice:

While migrating an app to take advantage of this new layout, it is suggested that a new project "base" is made with the CLI. Then, with the new project layout, migrate the features of the app piece by piece. Pages/components/etc. should be moved into the src/app/ folder.

If you are trying this by keeping your code in place and installing @ionic/angular in the current project rather than creating a NEW project and then copying code over feature by feature, then you are going to run into a lot of problems. If you are doing that, I suggest starting over employing the strategy outlined above. Having done a few of these myself, that is by far your best option.

查看更多
登录 后发表回答