0

I'm trying to install and instantiate chaincode in a hyperledger fabric network setup by me. I've written the chaincode in node.js and it installs perfectly from bash of cli container. But when I try to instantiate the chaincode it gives error after 5 minutes of wait. When I check the log of the short lived chaincode container which has exited after a few seconds I see just one line: npm ERR! missing script: start.

When I first got this error I had not included the start script in package.json and realised my mistake immediately. I included start script in package.json but I'm still getting this error after several retries. I've restarted network several times and pruned docker volumes aswell.

Why this error and how to resolve it?

Here's installation and instantiation(with error):

$ docker exec -it cli bash
root@2332c1945850:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install -n kyc -v 1.0 -p /opt/gopath/src/github.com/chaincode/ -l node
2019-04-23 19:42:50.134 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-04-23 19:42:50.134 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-04-23 19:42:50.784 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" > 
root@2332c1945850:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode instantiate -o orderer.kyc-example.com:7050 -C mychannel -n kyc -v 1.0 -c '{"Args":["init"]}' -P "OR ('BanksMSP.peer','Customer-portalMSP.peer')"
2019-04-23 19:43:11.083 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-04-23 19:43:11.083 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg timeout expired while starting chaincode kyc:1.0 for transaction

``````````````
$ docker ps -a            
CONTAINER ID        IMAGE                                                                                                      COMMAND                  CREATED             STATUS                     PORTS                                            NAMES
a7eca3bf67c5        dev-peer0.banks.kyc-example.com-kyc-1.0-85cfdbbf05d137aa76cf24ca528689e8342322e809595bfd41c384bd90f135f5   "/bin/sh -c 'cd /usr…"   6 seconds ago       Exited (1) 3 seconds ago 

Here's the log of this short lived chaincode container:
$ docker logs a7eca3bf67c5
npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-04-23T19_43_13_385Z-debug.log

````````````
Here's my package.json:
{
  "name": "kyc",
  "version": "1.0.0",
  "description": "kyc chaincode in node",
  "main": "kyc.js",
  "dependencies": {
    "fabric-shim": "~1.4.0"
  },
  "devDependencies": {},
  "scripts": {
    "start": "node kyc.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
``````````````



I expect it to not give this error as start script has been provided in package.json
  • Are you sure docker volume paths are correct ? Maybe it's looking for another package.json. – Nurullah Macun Apr 24 '19 at 08:06
  • Did you change the version number to 1.0.1 as well and install this new version onto the peer ? then you should instantiate the new version. – david_k Apr 24 '19 at 08:29
  • @NurullahMacun Even I suspected that, but the docker volume paths are correct for the cli container which is used to install and instantiate. I am thinking its not correct for this short lived chaincode container. Anyway to check? – Varan Shukla Apr 25 '19 at 05:59
  • @david_k Thank you so much! That did the trick. Can you explain how changing the version number helped. – Varan Shukla Apr 25 '19 at 07:03
  • If you use the same chaincode name and version number then if there are chaincode images with the same name and version number, these can be used instead of building a new one from the new code. Easiest approach is to always increment the version number when you plan to install a new version and instantiate or upgrade to this new code base. You should also look to removing old chaincode images periodically. – david_k Apr 26 '19 at 08:54

0 Answers0