Issues in the 'Fabcar' tutorial when bringing up a Kafka-based ordering service - hyperledger-fabric

I've brought up a Kafka-based ordering service in the Fabcar network by modifying some docker composition/configuration files, which is one of the tutorials on Hyperledger Fabric readthedocs.
These are the issues I've suffered from. Could you please tell me how to resolve them or even one of them?
I'd like to have containers start up in a specific order with 'wait-for-it.sh' script so that the orderer starts trying to connect to the Kafka cluster right after it is ready to perform commands. Do you happen to know how I should apply the script to my docker composition file?
When I executed "enrollAdmin.js" file in order to register an admin account with node enrollAdmin.js on the network in the same way as I did on the unmodified network,
This error message is shown and it doesn't work:
~/fabric-samples/fabcar/node_nodules/fabric-
client/lib/Client.js:746
async _createOrUpdateChannel(request, have_envelop) {
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected Identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/~/fabric-samples/fabcar/node_modules/fabric-client/index.js:25:18)
at Module._compile (module.js:570:32)
I took a look at Client.js file and was trying to understand how it works, but I have no idea what it is for and why it causes the issue.
Please help me resolve this issue if you know how.

Update Your nodejs .
check node version
node -v
It shoulb be greater than 8.0.0.

Related

How to solve this 'SyntaxError: Invalid regular expression' in pm2

I install node.js with pm2, all install fine but when i try to do pm2 monit give me this error.
$ pm2 monit
/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/tokenize.js:4
const TokenRule = /(?:%(?<flag>([+0-]|-\+))?(?<width>\d+)?(?<position>\d+\$)?(?<precision>\.\d+)?(?<conversion>[%BCESb-iosux]))|(\\%)/g;
^
SyntaxError: Invalid regular expression: /(?:%(?<flag>([+0-]|-\+))?(?<width>\d+)?(?<position>\d+\$)?(?<precision>\.\d+)?(?<conversion>[%BCESb-iosux]))|(\\%)/: Invalid group
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/tokenize.js:4:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/createPrintf.js:5:20)
at Module._compile (module.js:652:30)
I tried servers nodejs version and always give me this error.
If you paste your regular expression into a regex sandbox, like this one:
https://regex101.com/r/GkwWH2/1
You'll see that it doesn't show any syntax errors.
That would make me suspect that you're running a back-level version of Node JS. And in fact, if you look at your stack trace, you see that you are running Node 8.11.3
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fas
That regular expression is using features (such as named capture groups) that did not come into Node.js until Node v10.*.
I suggest you update to the latest LTS version of Node, version 14.*: from your stack trace it would appear that you're using NVM, so it should be a simple matter of
sudo nvm install lts/fermium
should do it.

Issues with Sharp in Azure functions

Hi I have been trying to deploy my code for resizing image streams in azure function.
It seems to be working perfectly fine in local, even deployment via VS code is successful.
But when I try to trigger the function, I get below exception.
Relatively new to both nodejs and azure, any suggestions?
2021-06-08T04:51:24.370 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=7bd3aba0-8833-4ffe-b2c7-a061533fef6a)
2021-06-08T04:51:24.444 [Error] Executed 'Functions.HttpTrigger1' (Failed, Id=7bd3aba0-8833-4ffe-b2c7-a061533fef6a, Duration=17ms)
Result: Failure
Exception: Worker was unable to load function HttpTrigger1: 'Error: 'win32-x64' binaries cannot be used on the 'win32-ia32' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'win32-ia32' platform.'
Stack: Error: 'win32-x64' binaries cannot be used on the 'win32-ia32' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'win32-ia32' platform.
at Object.hasVendoredLibvips (C:\home\site\wwwroot\node_modules\sharp\lib\libvips.js:82:13)
at Object.<anonymous> (C:\home\site\wwwroot\node_modules\sharp\lib\constructor.js:7:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\home\site\wwwroot\node_modules\sharp\lib\index.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
According to the error message, we need to update Azure function as 64 bit Platform. Regarding how to do that, please refer to here.

ReferenceError: window is not defined in godash

I am trying to build a board game and want to use godash to create a board state and update it. I have successfully installed godash into my package.json, but when I require it in the back-end, in my server.js (the file in which I run my server),
var godash = require ('godash');
and I run node server.js, the CLI responds with this error:
ReferenceError: window is not defined
at Object.<anonymous> (C:\Users\Chidi\gt\projects\Chess-vs-Go\node_modules\godash\dist\godash.js:1:194)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\Chidi\gt\projects\Chess-vs-Go\game_state\go_state.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
I've seen various "window is not defined" questions on this site in my effort to solve this problem, and the general solution seems to be that the code should be used in a browser environment. However, this is godash, an npm package that is to be used in the back-end. I have tried updating node.js and npm to their latest versions, but the problem still persists. I feel like I am making an obvious error that I can't see, because I went to the github page for godash and did not find any closed or open issues similar to this one. Does anyone know what the issue is, and how I can resolve it?
So, upon further research, I found that there are ways to use npm packages in the browser (e.g via browserify) This allowed me to use godash in the browser, where it was looking for a window object.

Cannot find librdkafka on Heroku

I am trying to get a simple Kafka consumer up and running on Heroku. I am using Node 8.11 and node-rdkafka. I have it running locally. When I try to run it on Heroku, I get this error:
Error: librdkafka++.so.1: cannot open shared object file: No such file or
directory
at Object.Module._extensions..node (module.js:681:18)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at bindings (/app/node_modules/bindings/bindings.js:81:44)
at Object.<anonymous> (/app/node_modules/node-rdkafka/librdkafka.js:10:32)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
I know the library is a wrapper for librdkafka and it looks like it just can't find it. According to the list of things preinstalled on Heroku Ubuntu instance, it looks like librdkafka-dev and librdkafka1 are installed. I don't know how to use those, or if something else is going on.
You have to use the Confluent librdkafka package.
Add this to your Aptfile:
:repo:deb [arch=amd64] http://packages.confluent.io/deb/4.0 stable main
Still having issues after doing this, but they are different issues and it looks like I'm closer.

Use edge js on openshift

I'm trying to run C# on my OpenShift cartridge with Edge.js. It runs really good on my Windows PC and I would like to have it running on the cloud.
I'm guessing it runs on a Linux environment but I'm not shure.
At first I tried to make it work with my MSSQL DB and than move on to the C# assembly.
Nevertheless I'm doing the same steps as how I've got it to work on my Windows machine but I'm getting thesame errors over and over again.
I've added edge and edge-sql to my npm and my package.json.
Then I've make a simple count to my MSSQL DB.
When I'm running it locally it works great. Than I push it to OpenShift and I tail the application, because the front-end gives me an Error 503, and the next thing I know the following error makes me keepings my hands in my hair.
Error: The edge native module is not available at /var/lib/openshift/54d26260fcf
933d05e00021a/app-root/runtime/repo/node_modules/edge/build/Release/edge.node. Y
ou can use EDGE_NATIVE environment variable to provide alternate location of edg
e.node. If you need to build edge.node, follow build instructions for your platf
orm at https://github.com/tjanczuk/edge
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/node_modules/edge/lib/edge.js:33:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/server.js:5:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'
/var/lib/openshift/54d26260fcf933d05e00021a/app-root/runtime/repo/node_modules/e
dge/lib/edge.js:33
throw new Error('The edge native module is not available at ' + builtEdge
Could somebody help me to fix this error or maybe explain to me why it could / wont work?
If edge requires a native windows environment to run C#, then it will not work on OpenShift, which runs on Red Hat Linux.

Resources