简体   繁体   中英

Nodejs cannot access Hyperledger composer showing errors

I am trying to build an example application using nodejs and Hyperledger-composer.

My system is Ubuntu 16.04. and I installed nodejs v8.10 using NVM. I am following the tutorial on the official Hyperledger composer ( check here ).

The problem I am having is on the connect() function to my " admin@borrow-network " business network:

this.businessNetworkDefinition = this.bizNetworkConnection.connect('admin@borrow-network');

The error that I am getting is the following:

Error: Failed to load connector module "composer-connector-hlfv1" for connection type "hlfv1". Must create ConnectionManager with a ConnectionProfileManager implementation.

I tried to include additional parameters inside the connect() function:

.connect('PeerAdmin@hlfv1', 'admin@borrow-network','admin','adminpw');

Then it showed a different error

UnhandledPromiseRejectionWarning: TypeError: Cannot create property 'cardName' on string 'admin@borrow-network' at cardStore.get.then(...././lib/businessnetworkconnection.js)

Am I doing something wrong? Please, any help is much appreciated.

1) you need Node 8.9.x or higher (eg, 8.11 etc - not node 9) 🙂 https://hyperledger.github.io/composer/installing/installing-prereqs.html suggest to uninstall old composer modules, get your node version up to speed using nvm then switch to that node version (8.9.x) and install composer modules (then the 'gyp' pre-compile issue gets resolved) etc as per https://hyperledger.github.io/composer/installing/development-tools

2) Don't use sudo or root privileges to install Composer (npm) modules - (you know that, just saying) - for npm errors / permission denied if you have such issues - suggest to follow the best practices here https://docs.npmjs.com/getting-started/fixing-npm-permissions including recommendation to install a Node Version Manager (install NVM then use that to manage Node installs) - more info here -> https://github.com/hyperledger/composer-knowledge-wiki/blob/latest/knowledge.md#information_source--composer-installation-issues (items 1, 2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM