我正在尝试运行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仍处于测试阶段。 有什么帮助吗?
I am trying to run an Angular 2 project and implemenet @angular/router.
The app works fine, until I try:
import { provideRouter, RouterConfig } from '@angular/router';because it tries to find:
http://localhost:3000/node_modules/@angular/router/bundles/router.umd.jswhich results in:
Error: GET http://localhost:3000/node_modules/@angular/router/bundles/router.umd.js 404 (Not Found)There is no /bundle/router.umd.js
Angular tries to find this file because of:
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' }; }Here is 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", ...I try and update the package using npm install @angular/router but get this error:
├── 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.7I realize Angular2 is still in Beta. Any help here?
最满意答案
我确定包会改变,因为它仍然是alpha,但在此之前你可以将它从ngPackageNames对象中取出并将其加载到packages对象中
'@angular/router': { main: 'index.js', defaultExtension: 'js' }我认为它还不符合其他模块的模式
这是我尝试过的一个例子,似乎得到了正确的路由器: Gist
I'm sure the package will change since it's still alpha but until then you could take it out of the ngPackageNames object and load it in the packages object as
'@angular/router': { main: 'index.js', defaultExtension: 'js' }I don't think it conforms with the other modules' pattern yet
Here is an example I tried and appears to get the correct router: Gist
更多推荐
发布评论