安装 hyperledger composer 时出现 EACCES

EACCES while installing hyperledger composer

我无法按照 https://hyperledger.github.io/composer/installing/development-tools.html 在 Ubuntu 系统上本地安装 hyperledger composer。我认为我已经满足所有要求:

ibmadmin@pfuntner1:~/hyperledger-composer$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
ibmadmin@pfuntner1:~/hyperledger-composer$ docker --version
Docker version 17.03.1-ce, build c6d412e
ibmadmin@pfuntner1:~/hyperledger-composer$ docker-compose --version
docker-compose version 1.13.0, build 1719ceb
ibmadmin@pfuntner1:~/hyperledger-composer$ node --version
v6.10.3
ibmadmin@pfuntner1:~/hyperledger-composer$ npm --version
3.10.10
ibmadmin@pfuntner1:~/hyperledger-composer$ git --version
git version 2.7.4
ibmadmin@pfuntner1:~/hyperledger-composer$ python --version
Python 2.7.12
ibmadmin@pfuntner1:~/hyperledger-composer$ code --version
1.15.1
41abd21afdf7424c89319ee7cb0445cc6f376959
ibmadmin@pfuntner1:~/hyperledger-composer$

当然,说明确实说我需要 git 2.9.x 或更高,但我只有 git 2.7.4,但我不确定这会导致问题或我遇到的具体问题。当我尝试安装 composer-cli 时,我得到:

ibmadmin@pfuntner1:~/hyperledger-composer$ npm install -g composer-cli
npm WARN deprecated fs-promise@1.0.0: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated crypto@0.0.3: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN deprecated nodemailer@2.7.2: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
/usr/lib
+-- composer-cli@0.11.3
  +-- chalk@1.1.3
.
.
.
    +-- yargs-parser@7.0.0
      +-- camelcase@4.1.0

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/composer-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.4.0-91-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "composer-cli"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ibmadmin/hyperledger-composer/npm-debug.log
ibmadmin@pfuntner1:~/hyperledger-composer$

我删除了大部分 npm install 输出,因为我认为它不相关而且它很长。

根据说明,我不是 运行 root 并且我没有权限访问 /usr/lib/node_modules 之类的路径,这并不奇怪。我来自一个空目录 运行,并且是唯一创建为 npm-debug.log 的东西。我该怎么办?

所以从根本上说这是一个 npm 问题。但是在上面的 npm 版本中看到它很奇怪。

正常路线是此处显示的路线之一 https://docs.npmjs.com/getting-started/fixing-npm-permissions

理想情况下,当您全局安装 composer 模块(例如 composer-cli)时,您应该使用指定的非 root 用户进行安装 - 正如您确实尝试过的那样。如果存在问题(例如,在 Ubuntu 上具有对位于 /usr/local 等系统目录中的 write/update 节点目录的权限)- 一种解决方案(但请参阅前面的 link)执行npm 安装到您有权访问的目录 - 而不是求助于 root 或超级用户访问权限,因为这不是好的做法。这是将 npm 前缀设置为给定目录的方法,...

"npm config set prefix /home/myuser/"

在这种情况下,全局二进制文件放置在您的 PATH 中的 /home/myuser/bin 中,模块放置在 /home/myuser/lib ...