Error when trying to bring up the test-network - hyperledger-fabric

I trying to follow tutorials and develope on MacOS ,When I want to run the next command to bring up the network./network.sh up,the error picture,but my env variable is set and have binaries and crypto folders.enter image description here,I don't know how to solve this problem, please help!

When peer binaries and config files are not found, it means that you need to set the path to locate the Hyperledger bin folder and point a fabric config environment variable to the config folder.
I tend to keep the bin and config up one level from the Hyperledger network code and have environment variables start off as the following
export FABRIC_CFG_PATH=$PWD/../config/
export PATH=${PWD}/../bin:$PATH
export IMAGE_TAG="latest"
export COMPOSE_PROJECT_NAME="net"
export CC_PACKAGE_VERSION=1
export CC_PACKAGE_SEQUENCE=1

Related

full-ICU works when passing the --icu-data-dir Node option, but not when using the NODE_ICU_DATA environment variable

Situation
I have an Alpine/NodeJS Docker image running my app (Alpine Linux 3.11, nodeJS v12.15.0), and I recently needed to internationalize currencies in this app.
I noticed that my container was missing locales, so I needed to install full-ICU. Consequently I modified my Alpine-based Docker image to add two lines to install full-ICU:
RUN npm i -g full-icu
ENV NODE_ICU_DATA=“/home/node/.npm/lib/node_modules/full-icu”
The installation went smoothly, the console output said:
Step 10/15 : RUN npm i -g full-icu
---> Running in b14d826c8689
/home/node/.npm/bin/node-full-icu-path -> /home/node/.npm/lib/node_modules/full-icu/node-icu-data.js
> full-icu#1.3.1 postinstall /home/node/.npm/lib/node_modules/full-icu
> node postinstall.js
npm install icu4c-data#64l (Node 12.15.0 and small-icu 64.2) -> icudt64l.dat
full-icu$ /usr/bin/node /home/node/.npm/lib/node_modules/npm/bin/npm-cli.js install icu4c-data#64l
+ icu4c-data#0.64.2
added 1 package from 1 contributor in 62.073s
√ icudt64l.dat (link)
Node will use this ICU datafile if the environment variable NODE_ICU_DATA is set to “/home/node/.npm/lib/node_modules/full-icu”
or with node --icu-data-dir=/home/node/.npm/lib/node_modules/full-icu YOURAPP.js
For package.json:
{"scripts":{"start":"node --icu-data-dir=/home/node/.npm/lib/node_modules/full-icu YOURAPP.js"}}
By the way, if you have full data, running this in node:
> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
... will show “enero”. If it shows “January” you don't have full data.
News: Please see https://github.com/icu-project/full-icu-npm/issues/6
+ full-icu#1.3.1
added 1 package from 1 contributor in 63.276s
It seems fine, it recognized my NodeJS version, there were no errors. I could check and see that the ICU data files were at the right place.
Problem
But when opening a shell inside this container (running docker run -ti myimage sh), and playing with Intl, I noticed that the locales were working properly only when running node with the --icu-data-dir option, not when using the NODE_ICU_DATA environment variable.
However, my preference definitely goes to the environment variable, for various reasons, so I would have liked it to work.
Tests so far
Here are my tests with node:
node --icu-data-dir=/home/node/.npm/lib/node_modules/full-icu
Welcome to Node.js v12.15.0.
Type ".help" for more information.
> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
'enero'
It's saying "enero", so it's working. It means that full-ICU is properly installed and reachable.
export NODE_ICU_DATA=“/home/node/.npm/lib/node_modules/full-icu”
node
Welcome to Node.js v12.15.0.
Type ".help" for more information.
> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
'January'
It doesn't care about my environment variable (also tried putting the environment variable in the Dockerfile, as shown above)
env NODE_ICU_DATA=“/home/node/.npm/lib/node_modules/full-icu” node
Welcome to Node.js v12.15.0.
Type ".help" for more information.
> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
'January'
It also doesn't care when the environment variable is inlined.
I also tried with .js scripts by the way, not just the NodeJS console, and also various ways to pass the environment variable.
And just to be sure, I tried to install system ICU packages, with RUN apk --update add --no-cache icu icu-libs icu-dev.
So...
Would anyone have an idea about the reason why specifying the path in an environment variable doesn't work, and what I should check?
I have the same issue with on a VPS with Plesk.
I can't update the Node version and the installed Node version is the, v12.4.0.
In my case I can't also install full-icu as global module, and the process manager start my app without run the start script in the package.json.
In this situation for me, the only way for load the full-icu support is to use the environment vars.
I tried first via command line:
export NODE_ICU_DATA=/full/path/of/my/app/node_modules/full-icu
and then
-bash-4.2$ /opt/plesk/node/12/bin/node
Welcome to Node.js v12.4.0.
Type ".help" for more information.
> new Intl.DateTimeFormat('it',{month:'long'}).format(new Date(9E8));
'gennaio'
>
it works fine.
It works too if I run this command in the root folder of my app:
NODE_ICU_DATA=node_modules/full-icu /opt/plesk/node/12/bin/node
So I added an ENV var on the app node setting (in Plesk)
NODE_ICU_DATA
with a value
node_modules/full-icu
Restarting the app the i18n support rightly works.
I hope this could help others people there are in my same situation.
For anyone falling on this issue: the problem was version-specific.
Deploying a more recent NodeJS version fixed these ICU bugs.

ENV variables not being loaded into build production

I have used dotenv module to load environment modules into a config file. When I execute that file using node config.js I know that it has been loaded successfully(used console.log and saw output on the terminal). But when I am trying to run the entire project, it comes out as undefined in the console of the browser. Can anyone have a particular reason as to why this is happening?
running node config.js would run the file for sure and env variable will be available only during the life of this script. that's the reason you are not getting env variable in other places. try to inject require('dotenv').config() in the right place where you are consuming them. e.g build script. hope it helps.

serverless - node.js crypto package is not working

Trying to generate RSA keys with crypto package and deploy it on AWS Lambda, I get an error that crypto package is undefined. Are there easy ways to deploy this package to Lambda without having building docker containers?
Yes, I read that node.js native packages have different binaries on mac (my current os) and linux, so there is an approach to build docker and deploy it, but I found it's not very clear for me, so if this is the only way to do it, maybe there are good resources to read about it also.
Thanks!
I tried to avoid docker as well but it's actually pretty easy to setup. Install the Community Edition
Pull this image with this:
docker pull lambci/lambda
To mount your dev folder run this:
docker run -v ~/[mydev-folder]:/var/task lambci/lambda:nodejs8.10
Open Kitematic from the Docker app. You should see the container you pulled. Select it and start it if it's not started. Then click "Exec" and you should get a bash prompt opened in /var/task which should be pointing at your dev folder.
I usually delete node_modules and then run npm install from inside the docker container. I also sls deploy from there was well.
You need to import the package as require("crypto"). It is just not defined on the global object.
const handler = () => {
console.log(crypto); // undefined
console.log(global.crypto); // undefined
console.log(require("crypto"); // Bingo! :D
}
If you arrived here because you are bundling a Nodejs lambda with rollup and using a version of uuid 7+, then you need to add
external: ["crypto"]
to your rollup.config.js so that rollup does not attempt to replace the require statement by whatever if finds better.

Problem on changing Hyperledger Composer version from 0.16.60 to 0.19.14

I am new in blockchain development. Actually i done a demo in composer vertion .16.6. Now i upgrade my composer vertion from 0.16.6 to 0.19.14. And i changed the code in createPeerAdmin.sh file for suitable to vertion 0.19.14. But always showing an error that
Connection profile has no x-type property defined. It is not valid for this version of composer
Please help me as possible.
Thanks
try to reset the environment variable for before starting or setup the development server using the following command by changing the fabric version u're going to use specific version from the development servers.
cd ~/fabric-dev-servers
export FABRIC_VERSION=hlfv11
./startFabric.sh
./createPeerAdminCard.sh
You can also find better information about the installation of the documentation in the link below:
https://hyperledger.github.io/composer/v0.19/installing/development-tools.html

How to configure nodejs on vscode extension on Mac

i use vscode on Mac for nodejs applications.
I installed the **Mocha Side Bar** module, for help me test my unit tests.
The problem is that vscode doesnt see the 'Nodejs' installation, and each time i try to execute the 'mocha test run', i am getting these errors:
The root of my nodejs installation is on that path: /Users/theodoros.itzaris/.nvm/versions/node/v6.11.5/bin/node
It seems a simple configuration issue, but i m new to both mac & vscode.
And i did not manage to find any tutorial on that.
You can specify an absolute path to your nodejs installation by setting the program attribute in your launch.json:
"program": "/Users/theodoros.itzaris/.nvm/versions/node/v6.11.5/bin/node"
All available launch configuration attributes can be found in this docs.
Update
Here is explained how the extension works and furthermore stated
It will search for the installed Node.js as indicated by environmental variable PATH
Therefore ensure that you have added node.js to your system's PATH variable.

Resources