简体   繁体   English

无法从 Hyperledger Fabric 2.2 注册管理员用户“admin”

[英]Failed to enroll admin user "admin" from Hyperledger Fabric 2.2

I'm trying to run the enrolladmin.js, but I'm receiving this error:我正在尝试运行 enrolladmin.js,但收到此错误:

Failed to enroll admin user "admin": TypeError: Cannot read property 'newFileSystemWallet' of undefined

The error shows Wallets as undefined at line:该错误将钱包显示为未定义行:

const wallet = await Wallets.newFileSystemWallet(walletPath); const wallet = await Wallets.newFileSystemWallet(walletPath);

From the enrolladmin.js:来自 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();

These are the current versions from what I'm using:这些是我正在使用的当前版本:

  • fabric_version: 2.2.0 fabric_version:2.2.0
  • fabric-ca_version 1.4.7 fabric-ca_version 1.4.7
  • node: v12.15.0节点:v12.15.0
  • npm: 6.13.4 npm:6.13.4

Does anyone know if I'm missing or should change anything?有谁知道我是否失踪或应该改变什么?

I tried and it is working.我试过了,它正在工作。 Just check the version of fabric.network library you are using.只需检查您正在使用的fabric.network库的版本。 newFileSystemWallet is in the latest version. newFileSystemWallet 是最新版本。 Here is the versions I am using -这是我使用的版本 -

"fabric-ca-client": "^2.2.11", "fabric-client": "^1.4.19", "fabric.network": "^2.2.11" “fabric-ca-client”:“^2.2.11”,“fabric-client”:“^1.4.19”,“fabric.network”:“^2.2.11”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法找到在 Fabcar 示例中注册管理员所需的模块 - Hyperledger Fabric - Unable to find modules required to enroll admin in Fabcar example - Hyperledger fabric 关于通过在 Hyperledger Fabric 中注册为 Nodejs 客户端创建的管理员/用户身份 - Regarding admin/user identities created for Nodejs Client via Enrollment in Hyperledger Fabric Hyperledger Fabric get User Private Key from Node.js SDK 2.2版本 - Hyperledger Fabric get User Private Key from Node.js SDK 2.2 version 使用节点 SDK 在超级账本结构中注册和注册时遇到错误 - facing error while enroll and register in hyperledger fabric using node SDK 超级账本结构调用注册端点失败并出现错误 - hyperledger fabric calling enrollment endpoint failed with error 从服务器登录用户的Firebase Admin SDK - Firebase Admin SDK to Log user in from Server Hyperledger Fabric:-来自尝试的对等通信的响应是一个错误:错误:在截止日期之前无法连接 - Hyperledger Fabric :- Response from attempted peer comms was an error: Error: Failed to connect before the deadline 将消息一个组织管理员发送到 hyperleger 结构中的另一个组织管理员 - send messages one organization admin to another organization admin in hyperleger fabric Hyperledger Fabric Version 2: How to query Block Header such as data hash, previous hash by using Fabric Node SDK 2.2 - Hyperledger Fabric Version 2: How to query Block Header such as data hash, previous hash by using Fabric Node SDK 2.2 无法从超级账本结构 getStateByRange 获得响应 - Trouble getting response from hyperledger fabric getStateByRange
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM