簡體   English   中英

安裝 composer-cli 時出錯

[英]errors installing composer-cli

我無法正確安裝 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
[~]$ 

看起來它仍在使用python3安裝。 您可以嘗試從您的 shell 中完全刪除python3或禁用嗎?

這是基於錯誤的結果:

$ 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

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

我通過 => 在我的 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。 我希望這有幫助 :):)

在 macOS Mojave(10.14.3) 節點版本:v8.15.1,nvm 版本:0.33.0,npm 版本:6.4.1 上運行 npm install -g composer-cli 時出現同樣的問題

終端 :

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.

您可能還想嘗試使用--unsafe-perm安裝...

它對我有用...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM