我在依赖项下的 package.json 中添加了@ ng-bootstrap / ng-bootstrap 1.0.0-alpha.23库。
的package.json
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.23",
"aes": "0.1.0",
"angular-in-memory-web-api": "~0.2.4",
"bootstrap": "^3.3.6",
"core-js": "^2.4.1",
"crypto-js": "^3.1.9-1",
"ng2-appinsights": "^0.3.0",
"applicationinsights-js": "^1.0.8",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4"
},
并在 system.js.config.js 文件
中添加了以下内容'@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',
system.js.config.js
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/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
'ng2-bootstrap': 'npm:ng2-bootstrap',
'@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'cryptojs': 'npm:crypto-js/crypto-js.js',
'ng2-appinsights': 'npm:ng2-appinsights',
'applicationinsights-js': 'npm:applicationinsights-js'
},
配置好所有内容并运行我的Angular2应用程序后,它会给出如下图所示的错误。
如何解决上述错误?
答案 0 :(得分:0)
尝试使用此功能。请参阅“node_modules'”的路径。它将解决问题。
'@ng-bootstrap': 'node_modules/@ng-bootstrap',
'@ng-bootstrap/ng-bootstrap': 'node_modules/@ng-bootstrap/ng-bootstrap'
或
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': {main: 'main.js', defaultExtension: 'js'},
'rxjs': {defaultExtension: 'js'},
'angular2-in-memory-web-api': {main: 'index.js', defaultExtension: 'js'},
'@ng-bootstrap/ng-bootstrap': {main: 'index.js', defaultExtension: 'js'}
};
答案 1 :(得分:0)
我在 system.js.config.js
中添加了以下两行代码 '@ng-bootstrap':'npm:@ng-bootstrap',
'@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js',
并将 node.js 更新为6.10.2,因为@ ng-bootstrap模块仅适用于此版本的node.js。
如果您想了解有关@ ng-bootstrap库的更多信息,请参阅以下链接。