[英]Unable to find modules required to enroll admin in Fabcar example - Hyperledger fabric
[英]Failed to enroll admin user "admin" from Hyperledger Fabric 2.2
我正在尝试运行 enrolladmin.js,但收到此错误:
Failed to enroll admin user "admin": TypeError: Cannot read property 'newFileSystemWallet' of undefined
该错误将钱包显示为未定义行:
const wallet = await Wallets.newFileSystemWallet(walletPath);
来自 enrolladmin.js:
"use strict";
const FabricCAServices = require("fabric-ca-client");
const { Wallets } = require("fabric-network");
const fs = require("fs");
const path = require("path");
async function main() {
try {
// load the network configuration
const ccpPath = path.resolve(
__dirname,
"..",
"..",
"..",
"..",
"home",
"my_user",
"goProject",
"fabric-samples",
"udemy_course",
"Fabric2.2",
"fabric-samples",
"test-network",
"organizations",
"peerOrganizations",
"org1.example.com",
"connection-org1.json"
);
const ccp = JSON.parse(fs.readFileSync(ccpPath, "utf8"));
// Create a new CA client for interacting with the CA.
const caInfo = ccp.certificateAuthorities["ca.org1.example.com"];
const caTLSCACerts = caInfo.tlsCACerts.pem;
const ca = new FabricCAServices(
caInfo.url,
{ trustedRoots: caTLSCACerts, verify: false },
caInfo.caName
);
// Create a new file system based wallet for managing identities.
const walletPath = path.join(process.cwd(), "wallet");
const wallet = await Wallets.newFileSystemWallet(walletPath);
// Check to see if we've already enrolled the admin user.
const identity = await wallet.get("admin");
if (identity) {
console.log(
'An identity for the admin user "admin" already exists in the wallet'
);
return;
}
console.log("---05");
// Enroll the admin user, and import the new identity into the wallet.
const enrollment = await ca.enroll({
enrollmentID: "admin",
enrollmentSecret: "adminpw",
});
console.log("---06");
const x509Identity = {
credentials: {
certificate: enrollment.certificate,
privateKey: enrollment.key.toBytes(),
},
mspId: "Org1MSP",
type: "X.509",
};
console.log("---07");
await wallet.put("admin", x509Identity);
console.log(
'Successfully enrolled admin user "admin" and imported it into the wallet'
);
} catch (error) {
console.error(`Failed to enroll admin user "admin": ${error}`);
process.exit(1);
}
}
main();
这些是我正在使用的当前版本:
有谁知道我是否失踪或应该改变什么?
我试过了,它正在工作。 只需检查您正在使用的fabric.network库的版本。 newFileSystemWallet 是最新版本。 这是我使用的版本 -
“fabric-ca-client”:“^2.2.11”,“fabric-client”:“^1.4.19”,“fabric.network”:“^2.2.11”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.