0

I am working on a box that has no internet. Successfully did ./byfn.sh and ./startFabric.sh in the fabcar after ftp into it all the required docker images, go files etc. However I am running into a problem while doing ./startFabric.sh typescript with the initial error as below

Error

/chaincode/output/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node" (not found)

The npm install and npm run build run successfully without errors in the /chanicode/fabcar/typescript and the file grpc_node.node is within the correct directory in the node_modules. So it appears that the container is not finding it. It is missing in the /var/lib/docker/overlay/xxxxxxxxxxxxxx/chaincode/ouptut/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl folder.

Please help.

When I run the npm rebuild command as per the instruction from murgatroid99 I have the following success ouput "[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" is installed via remote " However when I run "./startFabric.sh typescript" in the fabcar with in fabric 2.0 I get the following error

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.

Our boxes connect to an artifactory which is configured in .npmrc and cannot access internet. Artifactory has the node-v72-linux-x64-musl.tar.gz inside grpc/v1.24.2

1 Answers1

2

When you package Node chaincode, it will not include the node_modules folder. When the peer builds Node chain code, it uses a builder container (nodeenv) and essentially runs npm install.

The grpc package uses a native module and by default tries to pull down a prebuilt binary. If it cannot do this, it will try to build the native code from source. The error you are seeing has two parts:

  1. Cannot download the prebuilt binary
  2. Cannot download the Node.js headers required to build from source

We'll look into seeing if we can include the headers in the nodeenv image, but in the meantime it is possible to download prebuilt binaries from your own mirror.

I assume you are actually hosting the other required Node modules on Artifactory as well?

You'll need to host the prebuilt binary on internal server accessible from within a container. Artifactory should work for this. You'll need to host node-v72-linux-x64-musl.tar.gz on your internal server and it will need to be accessible at https://your_internal_server/grpc/v1.24.2/node-v72-linux-x64-musl.tar.gz.

In your .npmrc file, you'll need to add the line

grpc_node_binary_host_mirror=https://your_internal_server

and then the install process should download it from there rather than trying to get it from the public internet.

Gari Singh
  • 11,418
  • 2
  • 18
  • 41
  • where should the .npmrc file be kept? – maruti praturi Mar 18 '20 at 14:05
  • in your chain code source folder at the same level as your `package.json` – Gari Singh Mar 18 '20 at 17:10
  • I have quite a bit of experience with 1.4.2 and I had succeeded in running "./startFabric.sh typescript" in fabcar on RHEL7.0 without internet by configuring .npmrc file to point to the headers located in the enterprise artifactory. It just does not work with fabric 2.0 even though the .npmrc file is located in chaincode/fabcar/typescript, and in chaincode/fabric/typescript/dist and also in chaincode/fabcar/typescript/src. Problem is with "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)" – maruti praturi Mar 20 '20 at 06:26