fabric-samples icon indicating copy to clipboard operation
fabric-samples copied to clipboard

npm install fails ... "Type 'Client' is missing the following properties"

Open emgillis opened this issue 2 years ago • 10 comments

Tried to follow the "Running a Fabric Application" tutorial. The npm install process fails with an error of src/app.ts:47:9 - error TS2739: Type 'Client' is missing the following properties from type 'Client': [CHANNEL_SYMBOL], [INTERCEPTOR_SYMBOL], [INTERCEPTOR_PROVIDER_SYMBOL].

Full output is as follows:

application-gateway-typescript % npm install     

> [email protected] prepare
> npm run build


> [email protected] build
> tsc

src/app.ts:47:9 - error TS2739: Type 'Client' is missing the following properties from type 'Client': [CHANNEL_SYMBOL], [INTERCEPTOR_SYMBOL], [INTERCEPTOR_PROVIDER_SYMBOL]

47         client,
           ~~~~~~

  node_modules/@hyperledger/fabric-gateway/dist/gateway.d.ts:37:5
    37     client: Client;
           ~~~~~~
    The expected type comes from property 'client' which is declared here on type 'Readonly<ConnectOptions>'


Found 1 error.

npm ERR! code 2
npm ERR! path <<< my path structures >>>/application-gateway-typescript
npm ERR! command failed
npm ERR! command sh -c npm run build

Current environment:

% node --version
v18.14.0

% go version
go version go1.19.5 darwin/amd64

% jq --version
jq-1.6

% docker --version
Docker version 20.10.22, build 3a2c30b

% java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)

emgillis avatar Feb 11 '23 20:02 emgillis

Hi, I have the same problem, could you solve it?

juan-herrera-adl avatar Feb 18 '23 03:02 juan-herrera-adl

I couldn't. Even did on fully fresh install on different machine and had same issue

emgillis avatar Feb 18 '23 03:02 emgillis

I have downloaded this code through github clone in another directory and npm install worked fine. But I had to change some env variables (CRYPTO_PATH and CERT_PATH) with right paths to run the application.

juan-herrera-adl avatar Feb 19 '23 02:02 juan-herrera-adl

Interesting. Aside from finding these env variables referenced in the application-gateway-typescript/src/app.ts file (lines 19 and 25), I am curious where you found info on this? I honestly don't know what my paths should be for these variables. I couldn't find a reference anywhere in the Hyperledger documentation 😞

emgillis avatar Feb 23 '23 15:02 emgillis

Hi, I found the paths with the errors that showed me the application when I started. We need to reference the correct path to test-network. Example: export CRYPTO_PATH = [your_local_path]/test-network/organizations/peerOrganizations/org1.example.co export CERT_PATH = [your_local_path]/test-network/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]

juan-herrera-adl avatar Feb 23 '23 17:02 juan-herrera-adl

I have a similar but different problem like this ,and my log is

src/connect.ts:34:9 - error TS2322: Type 'Client' is not assignable to type 'GrpcClient'.
...........................................not importent things,
Property 'internalRepr' is protected but type 'Metadata' is not a class derived from 'Metadata'.
34         client,
           ~~~~~~
  node_modules/@hyperledger/fabric-gateway/dist/gateway.d.ts:58:5
    58     client: GrpcClient;
           ~~~~~~
    The expected type comes from property 'client' which is declared here on type 'Readonly<ConnectOptions>'
Found 1 error in src/connect.ts:34

step one: i try to click on the url up 58, change GrpcClient to Client , step two: we can see the name we created is cert.pem in msp, but in md is

    export ENDPOINT=org1peer-api.127-0-0-1.nip.io:8080
    export MSP_ID=org1MSP
    export CERTIFICATE=../../_cfg/uf/_msp/org1/org1admin/msp/signcerts/org1admin.pem
    export PRIVATE_KEY=../../_cfg/uf/_msp/org1/org1admin/msp/keystore/cert_sk

so let org1admin.pem ->cert.pem When I do this two step ,i can run it. This may pose a risk, but i'm just learning it, doing this will help me quick start.

AQBKX avatar Apr 26 '23 10:04 AQBKX

@bestbeforetoday Any suggestions or improvements needed in the sample/tutorials?

denyeart avatar May 02 '23 12:05 denyeart

Unfortunately issue of type compatibility with the gRPC Client object was triggered by a combination of (private) internal changes to the gRPC library between point releases, and the way TypeScript class definitions include private members when comparing type definitions. The fabric-gateway API was changed in v1.2.1 to use an interface rather than the concrete gRPC class to minimise the scope for incompatibility, although there still seem to have been some incompatibilities between public interfaces between gRPC point releases. This problem should have been solved by changes to fabric-sample made back in February in commit 10e9377555db46b7e46abccf2c8f1f0f3b78c995, which meant the sample applications used exactly the same grpc-js version as fabric-gateway. If there are still issues, it would be good to know the versions of dependencies used and I can try to reproduce the issue and then make things more robust based on what has broken.

On the certificate file name, I do spot a difference between the environment variables specified in these two exercises:

I'll see if I can submit a quick fix.

bestbeforetoday avatar May 02 '23 15:05 bestbeforetoday

Invoke the first step of the coordinated unit of work

peer chaincode invoke -o <orderer_address> -C <channel_name> -n <chaincode_name> -c '{"Args":["<function_name>", ""]}' --waitForEvent

Invoke the second step of the coordinated unit of work

peer chaincode invoke -o <orderer_address> -C <channel_name> -n <chaincode_name> -c '{"Args":["<function_name>", ""]}' --waitForEvent

... Repeat for each step of the coordinated unit of work

Replace <orderer_address> with the address of the orderer node, <channel_name> with the name of the channel, <chaincode_name> with the name of your chaincode, <function_name> with the name of the chaincode function, and with any required arguments for the function.

For more detailed information and a deeper understanding of the commands and options available, I recommend referring to the official Hyperledger Fabric documentation: https://hyperledger-fabric.readthedocs.io/

Hope it helps! Cheers

FawazMalik-jjj avatar Jun 14 '23 22:06 FawazMalik-jjj

@hyperledger/fabric-samples-maintainers I believe this issue is now resolved by a combination of the v1.2.1 release of @hyperledger/fabric-gateway and PR #927, and can be closed.

bestbeforetoday avatar Sep 15 '23 10:09 bestbeforetoday