John
John

Reputation: 329

EACCES while installing hyperledger composer

I'm having difficulty installing the hyperledger composer locally on a Ubuntu system as per https://hyperledger.github.io/composer/installing/development-tools.html. I think I've met all of the requirements:

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$

Granted, the instructions do say I need git 2.9.x or higher and I only have git 2.7.4 but I am not sure that would cause a problem or the specific problem I'm seeing. When I try to install composer-cli, I get:

ibmadmin@pfuntner1:~/hyperledger-composer$ npm install -g composer-cli
npm WARN deprecated [email protected]: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: 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 [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Deprecated, use jstransformer
npm WARN deprecated [email protected]: 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
+-- [email protected]
  +-- [email protected]
.
.
.
    +-- [email protected]
      +-- [email protected]

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

I removed much of the npm install output because I didn't think it was relevant and it was quite long.

As per the instructions, I am not running as root and am not surprised I don't have the access the install wants to a path like /usr/lib/node_modules. I was running from an empty directory and the only thing that was created as npm-debug.log. What should I do?

Upvotes: 2

Views: 2223

Answers (1)

Paul O'Mahony
Paul O'Mahony

Reputation: 6740

So fundamentally this is an npm issue. But strange to see it with your npm version above.

The normal route is one of these shown here https://docs.npmjs.com/getting-started/fixing-npm-permissions

Ideally, when you install composer modules globally (eg. composer-cli) you should install using a designated, non-root user - as you indeed tried to do. If there are issues (eg, on Ubuntu with permissions to write/update node directories located in system directories like /usr/local) - one solution (but see link earlier) is perform the npm install to a directory you have access to - rather than resort to root or superuser access, as this is not good practice. Here is what to do to set the npm prefix to a given directory, ...

"npm config set prefix /home/myuser/"

In this case, global binaries are placed in /home/myuser/bin which is in your PATH, and the modules are placed in /home/myuser/lib ...

Upvotes: 5

Related Questions