404找到router.umd.js,Angular 2(404 router.umd.js Not Found, Angular 2)

编程入门 行业动态 更新时间:2024-10-28 21:30:40
404找到router.umd.js,Angular 2(404 router.umd.js Not Found, Angular 2)

我正在尝试运行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.js

which 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.7

I 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

更多推荐

本文发布于:2023-08-06 13:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448671.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:router   umd   Angular   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!