【发布时间】:2018-10-14 08:03:35
【问题描述】:
我构建了一个 Angular 5 应用程序,目标是从卡片存档中加载 BusinessNetworkDefinition。我似乎无法弄清楚如何在我的 Angular 应用程序中动态加载模块。当我加载卡片存档文件,然后尝试通过以下代码连接到正在运行的业务网络时,我收到错误消息。
private fileAccepted(file: File): void {
let fileReader = new FileReader();
fileReader.readAsArrayBuffer(file);
fileReader.onloadend = () => {
this.cardService.importCard(fileReader.result).then((card) => {
this.card = card;
const connProfile = this.card.getConnectionProfile();
this.connectionProfileManager.connectWithData(this.card.getConnectionProfile(), this.card.getBusinessNetworkName())
.then((connection) => {
console.log(connection);
})
.catch((err) => {
console.log(err);
});
});
}
这是抛出的错误:
Error: Failed to load connector module "composer-connector-hlfv1" for connection type "hlfv1". curmod.require is not a function-connectionManagerLoader.require is not a function-Cannot find module "."
at Promise.resolve.then (connectionprofilemanager.js:144)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:4760)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4751)
at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
为了给这种情况添加更多上下文,我在使用 webpack 编译时还收到以下错误:
WARNING in ./node_modules/composer-common/lib/connectionprofilemanager.js
132:57-69 Critical dependency: the request of a dependency is an expression
@ ./node_modules/composer-common/lib/connectionprofilemanager.js
@ ./node_modules/composer-common/index.js
@ ./src/app/services/identity-card.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi (webpack)-dev-server/client?http://localhost:4200 ./src/main.ts
我怀疑这与动态加载的模块有关,但我已经查看并尝试了以下问题/帖子中包含的所有解决方案:
- https://github.com/webpack/webpack/issues/196
- https://github.com/hyperledger/composer/issues/3952
- Unable to dynamically load npm-modules in ionic
我希望有人能从技术上解释这里发生了什么以及我应该在哪里寻找解决方案。谢谢!
【问题讨论】:
标签: angular hyperledger-composer