hyperledger / fabric-samples

Samples for Hyperledger Fabric
https://wiki.hyperledger.org/display/fabric
Apache License 2.0
2.77k stars 3.36k forks source link

rest-api-typescript getting error #962

Open sohailrafique2017 opened 1 year ago

sohailrafique2017 commented 1 year ago

EnvVarError: env-var: "HLF_CONNECTION_PROFILE_ORG1" is a required variable, but it was not set. An example of a valid value would be: {"name":"test-network-org1","version":"1.0.0","client":{"organization":"Org1" ... } at raiseError (/Users/mac/Documents/projects/company/hyperledger/hyperledger_typscript/network/apis/node_modules/env-var/lib/variable.js:47:11) at Object.asJsonObject (/Users/mac/Documents/projects/company/hyperledger/hyperledger_typscript/network/apis/node_modules/env-var/lib/variable.js:64:11) at Object. (/Users/mac/Documents/projects/company/hyperledger/hyperledger_typscript/network/apis/src/config.ts:187:4) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Module.require (internal/modules/cjs/loader.js:1019:19) at require (internal/modules/cjs/helpers.js:77:18) at Object. (/Users/mac/Documents/projects/company/hyperledger/hyperledger_typscript/network/apis/src/index.ts:9:1)

sohailrafique2017 commented 1 year ago

How Can I set env variables HLF_CONNECTION_PROFILE_ORG1??

caner-emec commented 1 year ago

@sohailrafique2017 In the readme file it says: "Create a .env file to configure the server for the test network (make sure TEST_NETWORK_HOME is set to the fully qualified test-network directory)" TEST_NETWORK_HOME=$HOME/fabric-samples/test-network npm run generateEnv

https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-basic/rest-api-typescript/scripts/generateEnv.sh If you want to create manually, you can review the above file. The code here shows how the env. variable is created.

Or you can just try to export the created .env file.