1. 程式人生 > >fabric V1.0 sdk nodejs搭建手冊

fabric V1.0 sdk nodejs搭建手冊

1.1 安裝nodejs 1.1.1 更新ubuntu軟體源 sudo apt-get update sudo apt-get install -y python-software-properties software-properties-common sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update 1.1.2 安裝nodejs sudo apt-get install nodejs sudo apt install nodejs-legacy sudo apt install npm 1.1.3 更新npm的包映象源,方便快速下載 sudo npm config set registry

https://registry.npm.taobao.org sudo npm config list 1.1.4全域性安裝n管理器(用於管理nodejs版本) sudo npm install n -g 1.1.5安裝最新的nodejs(stable版本) sudo n stable sudo node -v 1.2 安裝sdk 1.2.1下載fabric-samples cd /opt/gopath/src/github.com/hyperledger/ git clone https://github.com/hyperledger/fabric-samples 1.2.2啟動網路 cd /opt/gopath/src/github.com/hyperledger/fabric-samples/balance-transfer docker-compose -f artifacts/docker-compose.yaml up 修改package.json { “name”: “balance-transfer”, “version”: “1.0.0”, “description”: “A balance-transfer example node program to demonstrate using node.js SDK APIs”, “main”: “app.js”, “scripts”: { “start”: “node app.js” }, “keywords”: [ “fabric-client sample app”, “balance-transfer node sample”, “v1.0 fabric nodesdk sample” ], “engines”: { “node”: “8.9.4”, “npm”: “5.6.0” }, “license”: “Apache-2.0”, “dependencies”: { “body-parser”: “^1.17.1”, “cookie-parser”: “^1.4.3”, “cors”: “^2.8.3”, “express”: “^4.15.2”, “express-bearer-token”: “^2.1.0”, “express-jwt”: “^5.1.0”, “express-session”: “^1.15.2”, “fabric-ca-client”: “^1.0.2”, “fabric-client”: “^1.0.2”, “fs-extra”: “^2.0.0”, “jsonwebtoken”: “^7.3.0”, “log4js”: “^0.6.38” } } 1.2.3安裝node 的fabric-ca-client和fabric-client (1)安裝依賴 npm install node-gyp npm install node-pre-gyp npm install grpc npm install (2)請安裝jq Sudo apt-get install jq (3)啟動node服務 PORT=4000 node app