Iva*_*ers 6 node-modules typescript systemjs angular
在Angular2中配置外部项目总是遇到一些麻烦.
我想在我的项目中包含ng2-sharebuttons.(似乎没有全局.d.ts
文件?)
虽然README.md
只是说npm install ng2-sharebuttons --save
,我知道还有更多的东西(systemjs.config
&typings
)
首先,我尝试配置systemjs.config
:
map{
......
'ng2-sharebuttons' : 'node_modules/ng2-sharebuttons'
}
Run Code Online (Sandbox Code Playgroud)
这至少固定在404
上localhost/ng2-sharebuttons
,但创造了一个新404
的localhost/node_modules/ng2-sharebuttons
.
所以,我添加了一个主文件,systemjs.config
改为
map{
......
'ng2-sharebuttons' : 'node_modules/ng2-sharebuttons/dist/index.js'
}
Run Code Online (Sandbox Code Playgroud)
但现在这导致了404
每个孩子ng2-sharebuttons/dist
我尝试过typings install ng2-sharebuttons --save --global
,typings install @types/ng2-sharebuttons --save --global
无论有没有--global
旗帜.
所以在我最后的希望中,我添加了一个参考,看看是否可行.添加
/// <reference path="../../node_modules/ng2-sharebuttons/dist/index.d.ts" />
但这并没有改变任何事情.
我忘记了什么?为什么这么难?(或者我只是努力吗?)
结构和文件ng2-sharebuttons
:
最后,Chrome目前正在生成错误消息:
整个 systemjs.config.js
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angularfire2' : 'npm:angularfire2/bundles/angularfire2.umd.js',
'firebase' : 'npm:firebase',
'ng2-bs3-modal': 'npm:ng2-bs3-modal',
'ng2-sharebuttons' : 'npm:ng2-sharebuttons/dist/index.js',
'ng2-social-share' : 'npm:ng2-social-share/bundles/ng2-social-share.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
firebase: {
main: './firebase-browser.js',
defaultExtension: 'js'
}
}
});
})(this);
Run Code Online (Sandbox Code Playgroud)
它抛出一个错误,GET .... 404
但XHR finished loading: GET ....
同样的组件/服务/文件,这似乎很奇怪.
你需要这样做
map:{
'ng2-sharebuttons' : 'npm:ng2-sharebuttons/dist'
},
packages: {
app: {main: './main.js', defaultExtension: 'js'},
rxjs: {defaultExtension: 'js'},
'ng2-sharebuttons': {main: 'index.js', defaultExtension: 'js'}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
547 次 |
最近记录: |