Chaincode实例化错误,日志显示npm err!缺少脚本:启动,即使存在带有启动脚本的package.json

时间:2019-04-23 20:04:22

标签: hyperledger-fabric hyperledger hyperledger-chaincode

我正在尝试由我在Hyperledger Fabric网络设置中安装和实例化chaincode。我已经在node.js中编写了链代码,它可以从cli容器的bash中完美安装。但是,当我尝试实例化chaincode时,它在等待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

0 个答案:

没有答案