简体   繁体   中英

Meteor + Angular2 - Cannot find name 'Router'

I'm trying to mix Meteor and Angular2 to one app with this tutorial enter link description here

Everything works without meteor but when it's running with meteor I got 2 errors :

Cannot find name 'Router'.

And

Cannot find name 'ActivatedRouteSnapshot'

.

The problem is I did "meteor npm install --save @angular/router" it was installed but nothing changed :/

My package.json

    {
    "name": "meteor-test",
    "private": true,
    "scripts": {
        "start": "meteor run",
        "desktop": "meteor-desktop -p 4000"
    },
    "dependencies": {
        "@angular/common": "4.2.6",
        "@angular/compiler": "4.2.6",
        "@angular/compiler-cli": "4.2.6",
        "@angular/core": "4.2.6",
        "@angular/forms": "4.2.6",
        "@angular/http": "4.2.6",
        "@angular/platform-browser": "4.2.6",
        "@angular/platform-browser-dynamic": "4.2.6",
        "@angular/platform-server": "4.2.6",
        "@angular/router": "4.3.1",
        "@ionic/storage": "^2.0.1",
        "angular2-cookie": "^1.2.6",
        "babel-runtime": "^6.20.0",
        "ionic-angular": "^3.5.0",
        "ionic-native": "^2.9.0",
        "ionicons": "^3.0.0",
        "meteor-node-stubs": "~0.2.4",
        "meteor-rxjs": "^0.4.7",
        "reflect-metadata": "^0.1.10",
        "rxjs": "^5.4.2",
        "zone.js": "^0.8.12"
    },
    "devDependencies": {
        "@types/meteor": "^1.4.2",
        "@types/meteor-accounts-phone": "0.0.5",
        "@types/underscore": "^1.8.1",
        "meteor-desktop": "^0.8.0",
        "meteor-typings": "^1.4.1"
    }
}

I found the solution in tsconfig.json file !

You have to remove this line :

"allowSyntheticDefaultImports": true,

I think that these are the classes that you should import:

import {
  RouterModule,
  Routes,
  ActivatedRoute
} from '@angular/router';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM