Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module './api' (Hyperledger composer)

After installing Hyperledger Composer cli from this page, I tried to call composer command but got this error:

module.js:549
throw err;
^

Error: Cannot find module './api'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/user/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/node-report/index.js:3:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

I used this command to install Hyperledger Composer:

npm install --unsafe-perm -g composer-cli

May I know what is going wrong?

like image 543
AshT Avatar asked Apr 10 '18 02:04

AshT


1 Answers

In my case I installed composer-cli in global /usr/lib/node_modules/composer-cli and I met the same problem. I don't know what's wrong but I tried:

  1. Change directory into the composer-cli:

    cd /usr/lib/node_modules/composer-cli

  2. Reinstall node report module, locally inside the composer-cli:

    sudo npm install node-report --unsafe-perm

Notice I don't put -g param in sudo npm install to make the installation local to the composer-cli itself.

The node-report will run make with g++ to compile something (which for some reason was not run during composer-cli installation) and it just works... Now I can run composer.

For your case set the working directory to /home/user/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli instead.

like image 197
Christian Lim Avatar answered Oct 06 '22 01:10

Christian Lim