我正在尝试运行Angular 2项目并实现@angular/router
。
应用程序正常,直到我尝试:
import { provideRouter, RouterConfig } from '@angular/router';
因为它试图找到:
http://localhost:3000/node_modules/@angular/router/bundles/router.umd.js
导致:
Error: GET http://localhost:3000/node_modules/@angular/router/bundles/router.umd.js 404 (Not Found)
没有/bundle/router.umd.js
Angular因以下原因尝试查找此文件:
var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];
// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}
以下是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/forms": "0.1.1",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/router": "3.0.0-alpha.7",
...
我尝试使用npm install @angular/router
更新软件包但出现此错误:
├── UNMET PEER DEPENDENCY @angular/core@2.0.0-rc.3
├── UNMET PEER DEPENDENCY @angular/http@2.0.0-rc.3
└── @angular/router@3.0.0-alpha.7
我发现Angular2仍然处于测试阶段。这里有什么帮助吗?
答案 0 :(得分:3)
我确定软件包会发生变化,因为它仍处于alpha状态,但在此之前,您可以将其从ngPackageNames对象中取出并将其加载到packages对象中
'@angular/router': { main: 'index.js', defaultExtension: 'js' }
我认为它不符合其他模块'模式
以下是我尝试过的一个示例,似乎可以获得正确的路由器:Gist