[英]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.