我正在尝试在我设置的超级账本结构网络中安装和实例化链代码。我已经在 node.js 中编写了链代码,它可以完美地从 cli 容器的 bash 中安装。但是当我尝试实例化链码时,它会在等待 5 分钟后给出错误。当我检查几秒钟后退出的短寿命链代码容器的日志时,我只看到一行:npm ERR!缺少脚本:开始。
当我第一次遇到这个错误时,我没有在 package.json 中包含启动脚本并立即意识到我的错误。我在 package.json 中包含了启动脚本,但在多次重试后仍然出现此错误。我已经多次重启网络并修剪了 docker 卷。
为什么会出现此错误以及如何解决?
这是安装和实例化(有错误):
$ 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