gpt4 book ai didi

typescript - 找不到 404 router.umd.js,Angular 2

转载 作者:太空狗 更新时间:2023-10-29 17:55:14 24 4
gpt4 key购买 nike

我正在尝试运行 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 仍处于测试阶段。有什么帮助吗?

最佳答案

我确信这个包会改变,因为它仍然是 alpha,但在那之前你可以将它从 ngPackageNames 对象中取出并加载到 packages 对象中作为

'@angular/router': { main: 'index.js', defaultExtension: 'js' }

我认为它还不符合其他模块的模式

这是我尝试并似乎获得正确路由器的示例:Gist

关于typescript - 找不到 404 router.umd.js,Angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38019436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com