[英]Angular2 System.js can't find jspm packages
I'm trying to write a simple Angular2 (using Alpha 47) app and I am trying to install "npm guid" from jspm. 我正在尝试编写一个简单的Angular2(使用Alpha 47)应用,并且正在尝试从jspm安装“ npm guid”。 It installs fine but when I try and run the app I always get "GET http://localhost:3001/jspm_packages/npm/guid@0.0.12 404 (Not Found)".
它安装得很好,但是当我尝试运行该应用程序时,我总是得到“ GET http:// localhost:3001/jspm_packages/npm/guid@0.0.12 404(未找到)”。 I've also tried to load other packages as well and they also come up with a 404. Otherwise my angular2 app works fine.
我也尝试加载其他程序包,它们还提供了404。否则,我的angular2应用程序可以正常工作。 I'm not sure what I am doing wrong.
我不确定自己在做什么错。 Any help would be really appreciated!
任何帮助将非常感激! Thanks!
谢谢!
System.js config file System.js配置文件
System.config({
baseURL: "/",
transpiler: "none",
paths: {
"npm:*": "jspm_packages/npm/*",
"github:*": "jspm_packages/github/*"
},
packages: {
"app": {
"defaultExtension": "js"
}
},
map: {
"guid": "npm:guid@0.0.12"
}
});
index.html index.html
<html>
<head>
<title>Office Contacts</title>
<link rel="stylesheet" href="app/styles/foundation.css">
<script src="jspm_packages/system.src.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>
<script src="config.js"></script>
<base href="/">
<script>
System.import('app/release/bootstrap');
</script>
<script src="node_modules/es6-shim/es6-shim.js"></script>
</head>
<body>
<app>Loading...</app>
</body>
</html>
My bootstrap.ts file 我的bootstrap.ts文件
//
// ANGULAR PROVIDERS
//
import {bootstrap, provide, FORM_PROVIDERS} from 'angular2/angular2';
import {ROUTER_PROVIDERS, HashLocationStrategy, LocationStrategy} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
import {ContactsService} from './contacts.service';
import {guid} from 'guid';
//
// APP COMPONENT
// Top level component that holds all of our components
//
import {App} from './app';
//
// BOOTSTRAP
// Bootstrap our app with the top level component and
// inject services and providers
//
bootstrap(App, [
FORM_PROVIDERS,
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
ContactsService,
guid,
provide(LocationStrategy, {useClass: HashLocationStrategy})
]);
Are you using Alpha 53? 您在使用Alpha 53吗? If so: They got rid of 'angular2/angular2'.
如果是这样:他们摆脱了“ angular2 / angular2”。 You have to import now using 'angular2/bootstrap', 'angular2/core'.
您现在必须使用“ angular2 / bootstrap”,“ angular2 / core”导入。
I'm actually having a potentially similar issue where 'angular2/bootstrap' isn't importing properly into SystemJS. 我实际上有一个潜在的类似问题,其中“ angular2 / bootstrap”未正确导入到SystemJS中。
https://github.com/angular/angular/blob/master/CHANGELOG.md https://github.com/angular/angular/blob/master/CHANGELOG.md
I see you only added "defaultExtension": "js"
for app
我看到您只为
app
添加了"defaultExtension": "js"
something is wrong with the extension, have you tried to copy the link into your browser http://localhost:3001/jspm_packages/npm/guid@0.0.12
, and then add .js
to see if it loads. 该扩展名出了点问题,您是否尝试过将链接复制到浏览器
http://localhost:3001/jspm_packages/npm/guid@0.0.12
,然后添加.js
以查看其是否加载。
try this 尝试这个
System.config({
map: { npm: 'jspm_packages/npm/' },
packages: {
npm: { defaultExtension: 'js' },
'app': {defaultExtension: 'js'}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.