WSL 2 Ubuntu Hyperledger Fabric npm 安装失败

时间:2021-01-05 13:43:42

标签: hyperledger-fabric

我正在尝试按照 hyperledger Fabric 上的文档运行第一个应用程序。当我在 asset-transfer-basic/application-javascript 时,尝试运行 npm install。它在下面抛出了一个错误:

> npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
> npm WARN deprecated har-validator@5.1.5: this library is no longer supported

> pkcs11js@1.2.0 install /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js
> node-gyp rebuild

> make ✖ ERR  Missing Makefile / Bakefile 
> make ℹ info Run "make init" to generate a Makefile.

> protobufjs@6.10.2 postinstall /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/protobufjs
> node scripts/postinstall

> npm notice created a lockfile as package-lock.json. You should commit this file.
> npm WARN asset-transfer-basic@1.0.0 No repository field.

> added 125 packages from 170 contributors and audited 125 packages in 21.417s

> 4 packages are looking for funding
  > run `npm fund` for details

> found 0 vulnerabilities.

按照说明,我转到文件夹 node_modules/pkcs11js 并运行 make init 以创建 Makefile。之后重新运行命令 npm install 和 node app.js。它仍然是同样的错误。即使我运行了 npm install -g pkcs11js,也没有解决问题。

当我运行 node app.js 时,它抛出:

internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module './build/Release/pkcs11.node'
Require stack:
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js/index.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/impl/bccsp_pkcs11.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/User.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/index.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/logger.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/impl/query/query.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/transaction.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/contract.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/network.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/gateway.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/index.js
- /mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js/index.js:5:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/pkcs11js/index.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/impl/bccsp_pkcs11.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/lib/User.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-common/index.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/logger.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/impl/query/query.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/transaction.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/contract.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/network.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/lib/gateway.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/node_modules/fabric-network/index.js',
    '/mnt/c/Users/DELL/Desktop/solarblock/chaincode/asset-transfer-basic/application-javascript/app.js'
  ]
}

我已经尝试解决了几天,仍然没有任何解决方案。

任何建议将不胜感激!

1 个答案:

答案 0 :(得分:1)

我也遇到过类似的错误,但它是在 fabcar 上工作时出现的,

似乎 pkcs11js 需要 node build-essential package, ie make 命令来构建包。

您似乎使用的是 windows 操作系统,请找到安装 node build-essential package 的方法。

对于Ubuntu,可以通过运行命令安装

$ sudo apt-get install build-essential

然后在您的节点应用程序的根目录(package.json 文件所在的位置)重新运行命令 npm install