安装composer-cli时出错

问题描述 投票:1回答:4

我无法正确安装composer-cli。我尝试用homebrew和其他方法卸载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 [email protected] install: `node-gyp rebuild`
16864 error Exit status 1
16865 error Failed at the [email protected] 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

> [email protected] 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 

> [email protected] 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

> [email protected] 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! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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
[~]$ 
node.js docker npm hyperledger-composer
4个回答
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
投票

OSX(Darwin 17.7.0)附带python 2.7,npm使用的许多底层脚本都期望并使用“旧样式”字符串格式化为“%”。如果你已经从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

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 [email protected]

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


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 [email protected]
/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

> [email protected] 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 

> [email protected] 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

> [email protected] 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! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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.
© www.soinside.com 2019 - 2024. All rights reserved.