2

I have installed all the prerequisites and i am getting following error while registering node admin after npm install. If anyone can please help me out with the error:-

hitesh@hitesh-VirtualBox:~/medication-blockchain/drug-app$ node registerAdmin.js
/home/hitesh/medication-blockchain/drug-app/node_modules/fabric-client/node_modules/grpc/src/grpc_extension.js:57
    throw e;
    ^

Error: Cannot find module '/home/hitesh/medication-blockchain/drug-app/node_modules/fabric-client/node_modules/grpc/src/node/extension_binary/node-v64-linux-x64-glibc/grpc_node.node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/hitesh/medication-blockchain/drug-app/node_modules/fabric-client/node_modules/grpc/src/grpc_extension.js:32:13)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Unknown14
  • 21
  • 5
  • Please note, i have done "npm install", "npm rebuild" everything. It is not working. The version is as mentioned"- npm version= 6.2.0, nodejs version= v10.7.0 – Unknown14 Jul 24 '18 at 10:43
  • Can you try using Node v8 rather than Node v10? – Gari Singh Jul 24 '18 at 10:46
  • But i am worried like backtracking a version would affect many of the config files right? @GariSingh – Unknown14 Jul 24 '18 at 10:51
  • fabric-client does not support Node 10 at this point ... it only support Node 8. So you'll need to remove your "node_modules" folder, switch to Node v8 and then run "npm install" again – Gari Singh Jul 24 '18 at 10:55
  • Ok great. So what are the exact steps, like just removing node_modules? and then directly installing node v8? @GariSingh setting paths or anything? – Unknown14 Jul 24 '18 at 10:57
  • I personally use "nvm" ( https://github.com/creationix/nvm ) in order to switch between Node versions. But yes ... you'd want to install Node v8, make sure that it's the default Node in your path, remove "node_modules" from your project and then run "npm install" – Gari Singh Jul 24 '18 at 11:12
  • Ok great, even i would try nvm to switch the version @GariSingh – Unknown14 Jul 25 '18 at 02:27
  • its done,thanks @GariSingh – Unknown14 Jul 25 '18 at 04:17

2 Answers2

1

Errors like the one in question most commonly show up because of installing gRPC on one platform/architecture/Node version, and then using it on a different one. This often comes up when loading an installed library into a docker image, or switching Node versions using nvm. In many cases, this can be resolved by running npm rebuild in the environment where the code will be run.

murgatroid99
  • 19,007
  • 10
  • 60
  • 95
0

When u cloned sample, u also copied the node_modules, which doesn't work with ur pc parameters. First, delete the node_modules, reinstall with npm install -g (globally), restart the app, works fine.

Stop all running containers, and remove them:
$docker stop $(docker ps -a -q)
$docker rm $(docker ps -a -q)

Delete node_modules:
$cd medication-blockchain/drug-app/node_modules

Restart from scratch:
$cd medication-blockchain/drug-app
$./startFabric.sh
$npm install -g
$node registerAdmin.js
$node registerUser.js
$node server.js