我用角度CLI开始了一个角度2.0项目;但是当我尝试使用路由时,它会抛出一些错误。目前,当我尝试运行'npm serve'时,显示的错误是 -
“Broccoli插件:[BroccoliTypeScriptCompiler]失败了: 错误:Typescript发现以下错误: H:/codes/animeSquad/tmp/broccoli_type_script_compiler-input_base_path-XUPT7Vob.tmp/0/src/app/app.routes.ts(5,10):Module'“H:/ codes / animeSquad / node_modules / @ angular / router / index“'没有导出的mng'RouterModule'。”
我的package.json内容就是这样 -
{
"name": "anime-squad",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"postinstall": "typings install",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "^2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-alpha.7",
"@angular/upgrade": "2.0.0",
"es6-shim": "0.35.1",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.31",
"zone.js": "0.6.12"
},
"devDependencies": {
"angular-cli": "1.0.0-beta.10",
"codelyzer": "0.0.20",
"ember-cli-inject-live-reload": "1.4.0",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "0.13.22",
"karma-chrome-launcher": "0.2.3",
"karma-jasmine": "0.3.8",
"protractor": "3.3.0",
"ts-node": "0.5.5",
"tslint": "3.11.0",
"typescript": "1.8.10",
"typings": "1.3.1"
}
}
我的目标是在保持CLI设置的同时启用路由。我对角度很新,所以很简单的详细解释将非常感激。
提前致谢。
答案 0 :(得分:0)
使用角度为rc5的"@angular/router" : "^3.0.0-rc.1"
,如果可能,请尝试使用最新版本的角度释放,因为 angular 2.0.0 已发布。
你可以看到问题的答案更新到最新的角度版本:
how to upgrade to angular2 official release from rc6 from webpack
答案 1 :(得分:0)
RC.2附带RC路由器,已被弃用。你需要安装vladivostok路由器:)
npm remove @angular/router --save
//将删除RC路由器
npm install @angular/router@3.0.0-alpha.7
--save //将安装最新的路由器