在Ubuntu上安装Composer时出错

时间:2017-08-22 16:36:46

标签: hyperledger-composer

我正在尝试在Ubuntu 14.04上安装Composer。我能够安装先决条件。安装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 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 node-uuid@1.4.8: Use uuid module instead
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/
/root/.nvm/versions/node/v6.11.2/bin/composer -> /root/.nvm/versions/node/v6.11.2/lib/node_modules/composer-cli/cli.js

> hashtable@2.0.2 install /root/.nvm/versions/node/v6.11.2/lib/node_modules/composer-cli/node_modules/hashtable
> node-gyp configure build

sh: 1: node-gyp: Permission denied
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/composer-cli/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! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! hashtable@2.0.2 install: `node-gyp configure build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the hashtable@2.0.2 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!     /root/.npm/_logs/2017-08-22T16_31_22_412Z-debug.log

1 个答案:

答案 0 :(得分:2)

首先,您不应将Hyperledger Composer安装为“root”。在继续https://hyperledger.github.io/composer/installing/development-tools.html

之前,您需要阅读此处的文档

所以从根本上说这是一个npm问题(因为当npm install作为'root'或'sudo'安装模块的权限时,它会导致npm出现问题。

我建议你在Ubuntu系统中创建一个非root用户。然后以该用户身份登录。然后使用上面链接中提供的prereqs-ubuntu.sh脚本安装pre-reqs。然后按照说明安装,作为非特权用户进行安装。

修复非root安装npm问题的正常途径,其中一个显示在https://docs.npmjs.com/getting-started/fixing-npm-permissions

当您全局安装编写器模块(例如,composer-cli)时,您应该使用指定的非root用户进行安装。如果存在问题(例如,在Ubuntu上有权编写/更新位于系统目录中的节点目录,如/ usr / local) - 一个解决方案(但请参见前面的链接)是对您可以访问的目录执行npm安装 - 而不是而不是诉诸于root或超级用户访问,因为这不是一个好习惯。以下是将npm前缀设置为给定目录的方法,...

“npm config set prefix / home / myuser /”

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