找不到模块; Hyperledger Fabric 教程

Cannot find module ; Hyperledger Fabric Tutorial

我正在尝试 运行 超级账本教程应用程序 (fabcar)。

我已经安装并尝试 运行 node query.js

我在终端上收到此错误:

module.js:529
    throw err;
    ^

Error: Cannot find module '/Users/pro/Documents/Code/HyperLegderFabric/fabric-samples/fabcar/node_modules/grpc/src/node/extension_binary/node-v57-darwin-x64/grpc_node.node'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/pro/Documents/Code/HyperLegderFabric/fabric-samples/fabcar/node_modules/grpc/src/node/src/grpc_extension.js:30:15)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)

我会感谢调试这个的指点

问题是我 运行 python 3.6 .

我最初使用过:

npm config set python python2.7

npm install --python=/usr/bin/python

甚至

sudo npm install --unsafe-perm  -g --python=python2.7

但问题是我只是 assumed python 2.7 在我的电脑上,允许我安装它。

当我 运行 node query.js 命令时,grpc_node.node 仍然是一个未解决的依赖项。

为了解决这个问题,我不得不

  • 删除fabric文件夹重新下载
  • 创建一个python 2.7 虚拟环境(conda create --name py2_env numpy python=2.7(我使用的是anaconda 发行版))
  • 运行 npm install

现在工作正常