1、node安装参考https://blog.csdn.net/CaptainJava/article/details/83866880
2、在搭建fabric IBM Marbles环境,在marbles/fabric-samples/fabcar下执行sudo npm install时node gyp安装报错
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
但是一直在找这个报错,也没有解决。其实是找错问题了,gyp固然是安装失败了 但是失败的原因在这个报错的前边几句,
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
当时报错为:
~/go/src/marbles/fabric-samples/fabcar ➦ 94c21eb sudo npm install
Password:> grpc@1.14.2 install /Users/grootma/go/src/marbles/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_librarynode-pre-gyp WARN Using request for node-pre-gyp https download
[grpc] Success: "/Users/grootma/go/src/marbles/fabric-samples/fabcar/node_modules/fabric-client/node_modules/grpc/src/node/extension_binary/node-v48-darwin-x64-unknown/grpc_node.node" is installed via remote> pkcs11js@1.0.16 install /Users/grootma/go/src/marbles/fabric-samples/fabcar/node_modules/pkcs11js
> node-gyp rebuildxcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instancexcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instanceTraceback (most recent call last):File "/usr/local/Cellar/nvm/0.33.11/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in
AttributeError: 'NoneType' object has no attribute 'groups'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/Cellar/nvm/0.33.11/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/nvm/0.33.11/versions/node/v6.11.1/bin/node" "/usr/local/Cellar/nvm/0.33.11/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/grootma/go/src/marbles/fabric-samples/fabcar/node_modules/pkcs11js
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
fabcar@1.0.0 /Users/grootma/go/src/marbles/fabric-samples/fabcar
└── (empty)npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none was installed.
npm WARN fabcar@1.0.0 No repository field.
npm ERR! Darwin 18.2.0
npm ERR! argv "/usr/local/Cellar/nvm/0.33.11/versions/node/v6.11.1/bin/node" "/usr/local/opt/nvm/versions/node/v6.11.1/bin/npm" "install"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLEnpm ERR! pkcs11js@1.0.16 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pkcs11js@1.0.16 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pkcs11js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs pkcs11js
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls pkcs11js
npm ERR! There is likely additional logging output above.npm ERR! Please include the following file with any support request:
npm ERR! /Users/grootma/go/src/marbles/fabric-samples/fabcar/npm-debug.log
npm ERR! code 1
是xcode 命令行工具的问题,在这我们重新设置一下xcode路径就好了(后边路径要去确认一下自己的xcode路径)
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
注意:当时设置完了,接着执行npm install时报错了 新的错误,
/Applications/Xcode.app/Contents/Developer sudo npm install
npm WARN enoent ENOENT: no such file or directory, open '/Applications/Xcode.app/Contents/Developer/package.json'
npm WARN Developer No description
npm WARN Developer No repository field.
npm WARN Developer No README data
npm WARN Developer No license field.
当时正好有事情就所有然见关掉,关机了,第二天打开电脑重新进行sudo npm install的时候结果成功了。没有在报错。所以肯呢个需要重启一下某些工具或者xcode。具体不清楚,反正我是重启电脑后就好了。。。如果有更好的解释或者更好的方法希望留言告知。
3、node install_chaincode.js 出现 Error('Cannot find org.', orgName):
root@xg:/opt/gopath/src/github.com/hyperledger/marbles/scripts# node install_chaincode.js
info: Loaded config file /opt/gopath/src/github.com/hyperledger/marbles/config/marbles_local.json
info: Loaded connection profile file /opt/gopath/src/github.com/hyperledger/marbles/config/connection_profile_local.json
Connection Profile Lib Functions:()
......
getAdminSignedCertPEM()
---------------------------------------
info: Lets install some chaincode - marbles v4
---------------------------------------
info: First we enroll
/opt/gopath/src/github.com/hyperledger/marbles/utils/connection_profile_lib/parts/org.js:102
throw new Error('Cannot find org.', orgName);
^
Error: Cannot find org.
该问题是由于 marbles\config\connection_profile_local.json中的 hfc-key-store 的绝对路径不正确导致的,需要更改是实际路径
(解决方法参考的:https://blog.csdn.net/u011127242/article/details/83450015)
将/Users/grootma/go/src/marbles/config/connection_profile_local.json文件中,三处"path"的值替换为Marble项目所在的绝对路径,只改前半部分后边不改动。即可。
4、在启动marbles服务,gulp marbles_local时报错
error: [Client.js]: Failed to load user "admin" from local key value store. Error: Error: Private key missing from key store. Can not establish the signing identity for user admin
错误,没找到admin用户的私钥,
将/Users/grootma/go/src/marbles/fabric-samples/fabcar/hfc-key-store文件夹下的文件复制到~/.hfc-key-store下,再次启动即可。