I’m using javascript to setup and run Hyperledger Fabric on my ubuntu system (24.04) and I’m getting this following error mentioned exactly below. Can anyone please suggest any solution?
Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 2f1e1593f1238327b55b89e8bb698d84e9b16099723490535a55846c4d5a93c5: could not launch chaincode fabcar_1:f2bcf8858a1682a45d5c3baa959d78e7d0ea8ebb28dac1c3466ebea7f443e452: chaincode registration failed: container exited with 1"
Invoke execution on peer0.org1 peer0.org2 failed
Deploying chaincode failed
I already tried moving back to previous node version such as 18.19.0, 18.16, 14.x but getting same error. I could successfully run it using golang and it works but I need it to run using javascript for rest of my work.
UPDATE:
This is the what I got after checking logs
ONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f9438fb7649 dev-peer0.org1.example.com-fabcar_1-6ab85d9d0ab315198d930d1b0eb8cf8c3f59849549226a86553e29eb1fbc0a12-b49b89823b3187a289804b3810ad318c833007d66f8d354640c50d486e3a18c6 "docker-entrypoint.s…" 21 minutes ago Exited (1) 21 minutes ago dev-peer0.org1.example.com-fabcar_1-6ab85d9d0ab315198d930d1b0eb8cf8c3f59849549226a86553e29eb1fbc0a12
721b236d1567 dev-peer0.org2.example.com-fabcar_1-6ab85d9d0ab315198d930d1b0eb8cf8c3f59849549226a86553e29eb1fbc0a12-1737f9501c52aea2e5e099b349ecb1e120b7bfc3375607a7fc4e64837deecd59 "docker-entrypoint.s…" 21 minutes ago Exited (1) 21 minutes ago dev-peer0.org2.example.com-fabcar_1-6ab85d9d0ab315198d930d1b0eb8cf8c3f59849549226a86553e29eb1fbc0a12
And this is the logs for the first container
+ CHAINCODE_DIR=/usr/local/src
+ cd /usr/local/src
+ npm start -- --peer.address peer0.org1.example.com:7052
> [email protected] start /usr/local/src
> fabric-chaincode-node start "--peer.address" "peer0.org1.example.com:7052"
Major failure to start fabic-chaincode-node
Error: Cannot find module 'node:path'
Require stack:
- /usr/local/src/node_modules/fabric-shim/lib/cmds/metadata/lib/generate.js
- /usr/local/src/node_modules/fabric-shim/lib/cmds/metadata.js
- /usr/local/src/node_modules/yargs/index.cjs
- /usr/local/src/node_modules/fabric-shim/cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/usr/local/src/node_modules/fabric-shim/lib/cmds/metadata/lib/generate.js:7:14)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/src/node_modules/fabric-shim/lib/cmds/metadata/lib/generate.js',
'/usr/local/src/node_modules/fabric-shim/lib/cmds/metadata.js',
'/usr/local/src/node_modules/yargs/index.cjs',
'/usr/local/src/node_modules/fabric-shim/cli.js'
]
}
2
Answers
I think your docker and docker-compose are installed with python3. I faced the same issue.
I downgraded to python 2.7 and then installed docker and docker-compose. Surprisingly that fixed the issue.
More recent v2.5.x versions of the fabric-shim package reference Node built-in packages using the
node:
prefix. For example,require('node:path')
. These prefixes for Node built-in packages were introduced as the preferred naming with Node 16. In earlier versions of Node, only the non-prefixed name was available. For example,require('path')
.By default, Fabric builds chaincode containers using a version of the chaincode Docker images tagged with the same major/minor version as the Fabric runtime. For example, Fabric v2.5.x builds Node chaincode containers using the
hyperledger/fabric-nodeenv:2.5
Docker image.From the fabric-chaincode-node COMPATIBILITY document, Node 16 became the runtime for the hyperledger/fabric-nodeenv Docker image at v2.4.x. Earlier versions of the Docker image (v2.2.x and v2.3.x) use Node 12.
It looks to me that you are depending on a v2.5.x version of the fabric-shim package while deploying to a version of Fabric earlier than Fabric v2.4. This means that the Node runtime within the chaincode container does not recognise the
require('node:path')
import used by the fabric-shim package version.I would recommend using a version of the fabric-shim and fabric-contract-api packages that match the Fabric major/minor version on which you are deploying. For example, if deploying to Fabric v2.2, depend on
fabric-shim@~2.2
. Note the~
semver specification. Depending onfabric-shim@^2.2
will resolve the most recent v2.x release, which would be v2.5.Ideally I would target the latest supported Fabric release. This will also allow you to target current supported Node versions. At the time of writing, this is Fabric v2.5 and the corresponding
fabric-shim@~2.5
, and using Node 20 as the runtime.