安装composer-cli

时间:2018-09-18 01:56:13

标签: node.js docker npm hyperledger-composer

我无法正确安装composer-cli。我尝试用自制软件和其他方法卸载node和npm。我收到与我的python安装有关的错误。所以我继续安装python2.7并指示npm使用它。这似乎解决了该特定错误,但随后出现了其他错误。如果有人在这个问题上有经验,我将不胜感激。谢谢!

日志文件:

16859 verbose argv "/Users/jcole/.nvm/versions/node/v8.12.0/bin/node" 
"/Users/jcole/.nvm/versions/node/v8.12.0/bin/npm" "install" "-g" "composer-cli"
16860 verbose node v8.12.0
16861 verbose npm  v6.4.1
16862 error code ELIFECYCLE
16863 error errno 1
16864 error node-report@2.2.1 install: `node-gyp rebuild`
16864 error Exit status 1
16865 error Failed at the node-report@2.2.1 install script.
16865 error This is probably not a problem with npm. There is likely additional logging output above.
16866 verbose exit [ 1, true ]

终端:

[~]$ npm install -g composer-cli
/Users/jcole/.nvm/versions/node/v8.12.0/bin/composer -> /Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/cli.js

> dtrace-provider@0.8.7 install /Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /usr/local/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:336:11)
gyp ERR! stack     at emitOne (events.js:116:13)
gyp ERR! stack     at Socket.emit (events.js:211:7)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:561:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/jcole/.nvm/versions/node/v8.12.0/bin/node" "/Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/node_modules/dtrace-provider
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> fsevents@1.2.4 install /Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/node_modules/fsevents
> node install

[fsevents] Success: "/Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> node-report@2.2.1 install /Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/node_modules/node-report
> node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /usr/local/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:276:12)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:336:11)
gyp ERR! stack     at emitOne (events.js:116:13)
gyp ERR! stack     at Socket.emit (events.js:211:7)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:561:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/jcole/.nvm/versions/node/v8.12.0/bin/node" "/Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jcole/.nvm/versions/node/v8.12.0/lib/node_modules/composer-cli/node_modules/node-report
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-report@2.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-report@2.2.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jcole/.npm/_logs/2018-09-18T01_49_06_082Z-debug.log
[~]$ 

5 个答案:

答案 0 :(得分:2)

看起来它仍在使用python3安装。您可以尝试完全删除python3或从shell禁用它吗?

这是基于错误的结果:

$ python -c 'import sys; print "%s.%s.%s" % sys.version_info[:3];'
2.7.15
$ python3 -c 'import sys; print "%s.%s.%s" % sys.version_info[:3];'
  File "<string>", line 1
    import sys; print "%s.%s.%s" % sys.version_info[:3];
                               ^
SyntaxError: invalid syntax

答案 1 :(得分:1)

我在Ubuntu 18.04计算机上通过=>

解决了相同的问题

https://hyperledger.github.io/composer/latest/installing/installing-prereqs.html上安装必备组件

上面写着->

curl -O https://hyperledger.github.io/composer/latest/prereqs-ubuntu.sh

然后     chmod u + x prereqs-ubuntu.sh 最后=>

./prereqs-ubuntu.sh

然后重新启动终端并尝试安装=>

npm install -g composer-cli@0.20

没有su或sudo。我希望这会有所帮助:):)

答案 2 :(得分:0)

OSX(Darwin 17.7.0)随python 2.7一起提供,npm使用的许多基础脚本都希望这样做,并使用带有“%”的“ Old Style”字符串格式。如果您已从2000年代后期升级到Python 3+,则此方法将无效。

每次(重新)安装有此问题的组件时,此问题都会弹出。反复卸载并重新安装python非常令人沮丧。

解决方法:暂时将OSX的原始python可执行文件放在$ PATH的开头,然后运行npm install。通常在/usr/bin中,所以请尝试:

$ GOODPATH=$PATH
$ export PATH=/usr/bin:$PATH
$ python --version
Python 2.7.10
npm install ....
$ export PATH=$GOODPATH
$ python --version
Python 3.7.2

答案 3 :(得分:0)

在macOS Mojave(10.14.3)上运行npm install -g composer-cli时发生了相同的问题 节点版本:v8.15.1, nvm版本:0.33.0, npm版本:6.4.1

终端:

MacBook-Air:~ shantanu$ npm install -g composer-cli@0.20
/Users/shantanu/.nvm/versions/node/v8.15.1/bin/composer -> /Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/cli.js

> dtrace-provider@0.8.7 install /Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:281:12)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:336:11)
gyp ERR! stack     at emitOne (events.js:116:13)
gyp ERR! stack     at Socket.emit (events.js:211:7)
gyp ERR! stack     at Pipe._handle.close [as _onclose] (net.js:561:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/Users/shantanu/.nvm/versions/node/v8.15.1/bin/node" "/Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/node_modules/dtrace-provider
gyp ERR! node -v v8.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> fsevents@1.2.7 install /Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download 
[fsevents] Success: "/Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote

> node-report@2.2.1 install /Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/node_modules/node-report
> node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:281:12)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/Users/shantanu/.nvm/versions/node/v8.15.1/bin/node" "/Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/shantanu/.nvm/versions/node/v8.15.1/lib/node_modules/composer-cli/node_modules/node-report
gyp ERR! node -v v8.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-report@2.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-report@2.2.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/shantanu/.npm/_logs/2019-03-16T10_22_33_184Z-debug.log

发生错误,因为它是使用python3安装的。卸载python3不是一个好选择,因此我暂时将python默认路径更改为OSX的原始pyhton路径

  $ GOODPATH=$PATH
    $ export PATH=/usr/bin:$PATH
    $ python --version
    Python 2.7.10

然后使用https://hyperledger.github.io/composer/latest/installing/development-tools.html

中提到的命令安装composer-cli

在成功安装composer-cli之后,更改了默认的python路径。

$ export PATH=$GOODPATH
$ python --version
Python 3.6.5 :: Anaconda, Inc.

答案 4 :(得分:0)

您可能还想尝试使用--unsafe-perm ...

进行安装

对我有用...