从Beta-17迁移到RC4后,我遇到的问题很少。我收到以下编译错误
Bootstrap Error
/// < reference path="../node_modules/angular2-in-memory-web-api/typings/browser.d.ts" >
import {bootstrap} from '@angular/platform-browser';
Error: Module "../platform-browser/index" as no exported member bootstrap
路由器错误
import {ROUTER_PROVIDERS, RouteConfig, ROUTER_DIRECTIVES, RouteParams, ROUTER_BINDINGS} from '@angular/router';
Error: Cannot find module '@angular/router'
我尝试使用路由器也弃用了,仍然没有找到模块错误
import {ROUTER_PROVIDERS, RouteConfig, ROUTER_DIRECTIVES, RouteParams, ROUTER_BINDINGS} from '@angular/router-deprecated';
Error: Cannot find module '@angular/router-deprecated'
如果不推荐使用现有路由器,那么实现路由的新方法是什么?
我在以下documentation网址中进行了验证,但未发现太多差异。
任何人都可以对此有所了解吗?
根据评论更新:新的错误集
我现在可以导入bootstrap和路由器,但是我收到了一些其他错误
错误#1。无法导入RouteConfig
import { ROUTER_DIRECTIVES, RouterOutlet, RouteConfig } from '@angular/router';
Error: Module "../angular/router/index has no exported member RouteConfig"
为了使路由器弃用能够工作,即我现有的路由实现,我需要导入 RouteConfig 。 我不知道从哪里可以导入 RouteConfig
除此之外,我得到了近210个编译错误,如下所示。当我搜索以下错误时,建议添加以下行
/// ../node_modules/angular2/typings/browser.d.ts" /&GT;
但作为迁移的一部分,我已添加以下行
/// < reference path="../node_modules/angular2-in-memory-web-api/typings/browser.d.ts" >
错误:
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\async.d.ts 34 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\async.d.ts 35 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 9 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 15 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 16 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 17 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 17 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 18 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 18 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 19 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 19 Active
Error TS2304 Cannot find name 'Promise'. TypeScript Virtual Projects ..\node_modules\@angular\core\src\facade\promise.d.ts 20 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\repeat.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\retry.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\retryWhen.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\sample.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\sampleTime.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\scan.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\share.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\single.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\skip.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\skipUntil.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\skipWhile.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\startWith.d.ts 2 Active
Error TS2664 Invalid module name in augmentation, module '../../Observable' cannot be found. TypeScript Virtual Projects ..\node_modules\rxjs\add\operator\subscribeOn.d.ts 2 Active
答案 0 :(得分:5)
答案 1 :(得分:2)
首先,尝试从以下位置获取引导功能:
import {bootstrap} from '@angular/platform-browser-dynamic';
其次,新路由器有一个全新的API,这意味着当你使用它时,你将从它导入不同的模块,它与已弃用的版本完全不同。可能最好尝试让router-deprecated
版本首先运行,因为您的beta.17版本的项目将主要与弃用的路由器一致。
未找到路由器模块的问题看起来好像您没有正确设置加载程序映射和/或打字和/或tsconfig。检查您的package.json
的内容和您的加载程序的配置(SystemJS / webpack)作为开始的英雄版本之旅。我发现对于升级ng2版本,这是最好的方法,因为文档很难找到并跟进升级。
希望这有帮助!