Angular2-未解析的路由器导入
我正在构建一个ionic2应用程序,我一直在遵循ionic framework官方网站上的Heroes示例,但在导入路由器指令时遇到了困难Angular2-未解析的路由器导入,angular,ionic2,Angular,Ionic2,我正在构建一个ionic2应用程序,我一直在遵循ionic framework官方网站上的Heroes示例,但在导入路由器指令时遇到了困难 import { provideRouter, RouterConfig } from '@angular/router'; export const routes: RouterConfig = [ { path: 'crisis-center', component: CrisisCenterComponent }, {
import { provideRouter, RouterConfig } from '@angular/router';
export const routes: RouterConfig = [
{ path: 'crisis-center', component: CrisisCenterComponent },
{ path: 'heroes', component: HeroListComponent },
{ path: 'hero/:id', component: HeroDetailComponent }];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];
这段代码产生的错误是:
未解析的provideRouter
未解析的路由配置
无法解析目录@angular
你知道为什么会这样吗
package.json文件如下所示:
{
"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/http": "2.0.0-rc.3",
"es6-shim": "^0.35.0",
"ionic-angular": "2.0.0-beta.10",
"ionic-native": "1.2.4",
"ionicons": "3.0.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
},
"devDependencies": {
"del": "2.2.0",
"gulp": "3.9.1",
"gulp-watch": "4.3.5",
"ionic-gulp-browserify-typescript": "2.0.0",
"ionic-gulp-fonts-copy": "^1.0.0",
"ionic-gulp-html-copy": "^1.0.0",
"ionic-gulp-sass-build": "^1.0.0",
"ionic-gulp-scripts-copy": "^2.0.0",
"run-sequence": "1.1.5"
},
"name": "test",
"description": "test: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": []
}
在我按照@MatWiligora的建议手动插入路由器依赖项之后,当我尝试执行npm安装时,出现了以下错误
npm WARN peerDependencies The peer dependency @angular/core@^2.0.0-rc.4 included from @angular/router will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency @angular/compiler@^2.0.0-rc.4 included from @angular/router will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency @angular/common@^2.0.0-rc.4 included from @angular/router will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency @angular/platform-browser@^2.0.0-rc.4 included from @angular/router will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency @angular/platform-browser-dynamic@^2.0.0-rc.4 included from @angular/router will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
及
确保您正在安装“@angular/router”:“3.0.0-beta.2”作为您在package.json中的依赖项,即路由器的当前版本
您是否也将:APP\u ROUTER\u PROVIDERS注入您的引导程序?您是否可以共享您的package.json?@Sanket我已经包含了上面的package.json!依赖项中缺少@angular/router。请按照下面的回答更新。@Sanket谢谢!有没有快捷方式来更新它?angular2是一个s*it。。。如此多的依赖性问题,它正在更新,所以rapidly@MatValigora我已经在上面的帖子中包含了json文件。此外,当我尝试注入APP_Router_提供者时,我也无法做到这一点,因为我导入的APP_Router_提供者显示未解析的APP_Router_提供者如我所说,请在package.json中的依赖项中添加:“@angular/Router”:“3.0.0-beta.2”。谢谢!手动插入是否可以解决此问题?是否应该通过一个命令来安装它,该命令也会更新节点_模块内的angular2模块?您可以手动插入它,然后通过终端执行npm安装。将此行“router”添加到systemjs.config.js文件中的packageNames数组中
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package @angular/common@2.0.0-rc.3 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/router@3.0.0-beta.2 wants @angular/common@^2.0.0-rc.4
npm ERR! peerinvalid Peer @angular/platform-browser@2.0.0-rc.3 wants @angular/common@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/platform-browser-dynamic@2.0.0-rc.3 wants @angular/common@2.0.0-rc.3
npm ERR! peerinvalid Peer ionic-angular@2.0.0-beta.10 wants @angular/common@^2.0.0-rc.3
npm ERR! Please include the following file with any support request:
npm ERR! npm-debug.log