0

我正在研究一个没有互联网的盒子。在 ftp 进入所有必需的 docker 映像、go 文件等之后,在 fabcar 中成功完成了 ./byfn.sh 和 ./startFabric.sh。但是我在执行 ./startFabric.sh 打字稿时遇到了问题,初始错误为以下

错误

/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node”(未找到)

npm install 和 npm run build 在 /chanicode/fabcar/typescript 中成功运行且没有错误,并且文件 grpc_node.node 位于 node_modules 中的正确目录中。所以看起来容器没有找到它。/var/lib/docker/overlay/xxxxxxxxxxxxxx/chaincode/ouptut/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl 文件夹中缺少它。

请帮忙。

当我按照 murgatroid99 的指令运行 npm rebuild 命令时,我有以下成功输出“[grpc] Success:”/home/mp70332/fab2.0/fabric-samples-master/chaincode/fabcar/typescript/node_modules/grpc /src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node”是通过远程安装的”但是当我在fabcar中使用fabric 2.0运行“./startFabric.sh typescript”时,我收到以下错误

grpc@1.24.2 install /chaincode/output/node_modules/grpc
node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.14.0
node-pre-gyp info using node@12.9.1 | linux | x64
node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp info check checked for "/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node" (not found)
node-pre-gyp http GET https://node-precompiled-binaries.grpc.io/grpc/v1.24.2/node-v72-linux-x64-musl.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for grpc@1.24.2 and node@12.9.1 (node-v72 ABI, musl) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error getaddrinfo ENOTFOUND node-precompiled-binaries.grpc.io 
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@12.9.1 | linux | x64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.3
gyp info using node@12.9.1 | linux | x64
gyp info find Python using Python version 2.7.16 found at "/usr/bin/python"
gyp http GET https://nodejs.org/download/release/v12.9.1/node-v12.9.1-headers.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: This is most likely not a problem with node-gyp or the package itself and
gyp ERR! stack is related to network connectivity. In most cases you are behind a proxy or have bad 
gyp ERR! stack network settings.
gyp ERR! stack     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:170:21)
gyp ERR! stack     at Request.emit (events.js:209:13)
gyp ERR! stack     at Request.onRequestError (/usr/local/lib/node_modules/npm/node_modules/request/request.js:881:8)
gyp ERR! stack     at ClientRequest.emit (events.js:209:13)
gyp ERR! stack     at TLSSocket.socketErrorListener (_http_client.js:406:9)
gyp ERR! stack     at TLSSocket.emit (events.js:209:13)
gyp ERR! stack     at emitErrorNT (internal/streams/destroy.js:91:8)
gyp ERR! stack     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:77:11)
gyp ERR! System Linux 3.10.0-1062.9.1.el7.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node" "--module_name=grpc_node" "--module_path=/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /chaincode/output/node_modules/grpc
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/chaincode/output/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Linux 3.10.0-1062.9.1.el7.x86_64
node-pre-gyp ERR! command "/usr/local/bin/node" "/chaincode/output/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /chaincode/output/node_modules/grpc
node-pre-gyp ERR! node -v v12.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.24.2 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the grpc@1.24.2 install script.

我们的盒子连接到一个在 .npmrc 中配置的工件,并且无法访问互联网。Artifactory 在 grpc/v1.24.2 中有 node-v72-linux-x64-musl.tar.gz

4

1 回答 1

2

打包 Node 链码时,它不会包含 node_modules 文件夹。当 peer 构建 Node 链代码时,它使用一个构建器容器(nodeenv)并且本质上运行npm install.

grpc软件包使用本机模块,默认情况下会尝试下载预构建的二进制文件。如果它不能做到这一点,它将尝试从源代码构建本机代码。您看到的错误有两个部分:

  1. 无法下载预构建的二进制文件
  2. 无法下载从源代码构建所需的 Node.js 标头

我们将研究是否可以在nodeenv映像中包含标头,但同时可以从您自己的镜像下载预构建的二进制文件。

我假设您实际上也在 Artifactory 上托管其他必需的节点模块?

您需要将预构建的二进制文件托管在可从容器内访问的内部服务器上。Artifactory 应该为此工作。您需要托管node-v72-linux-x64-musl.tar.gz在您的内部服务器上,并且需要在https://your_internal_server/grpc/v1.24.2/node-v72-linux-x64-musl.tar.gz.

在您的.npmrc文件中,您需要添加该行

grpc_node_binary_host_mirror=https://your_internal_server

然后安装过程应该从那里下载它,而不是尝试从公共互联网上获取它。

于 2020-03-12T10:34:53.160 回答