ionic node Error: Path must be a string. Received { [String: - node.js

i have problem when try to build ionic app
this error
SyntaxError: Use of const in strict mode
i think the problem was the node version ,so i install the latest version
when i try to run : ionic build android
Error: Path must be a string. Received { [String:
'C:\\PROGRAM FILES\\NODEJS\\NO
DE.EXE']
stdout: 'C:\\PROGRAM FILES\\NODEJS\\NODE.EXE',
stderr: null,
code: 0,
cat: [Function: bound ],
exec: [Function: bound ],
grep: [Function: bound ],
head: [Function: bound ],
sed: [Function: bound ],
sort: [Function: bound ],
tail: [Function: bound ],
to: [Function: bound ],
toEnd: [Function: bound ],
uniq: [Function: bound ] }
and when i try to run : cordova plugin add cordova-plugin-whitelist
Error: Path must be a string. Received { [String: 'D:\\PHONE GAP\\PROJECTS\\RENT
CLUB\\PLATFORMS\\ANDROID\\CORDOVA\\VERSION.BAT']
stdout: 'D:\\PHONE GAP\\PROJECTS\\RENTCLUB\\PLATFORMS\\ANDROID\\CORDOVA\\VERSI
ON.BAT',
stderr: null,
code: 0,
cat: [Function: bound ],
exec: [Function: bound ],
grep: [Function: bound ],
head: [Function: bound ],
sed: [Function: bound ],
sort: [Function: bound ],
tail: [Function: bound ],
to: [Function: bound ],
toEnd: [Function: bound ],
uniq: [Function: bound ] }
any ideas ?
and thankyou

I will suggest to re install all the things from node here, git here, cordova and ionic.
you can check node version by command npm -v and git version by git --version
For Cordova : npm install -g cordova
For Ionic : npm install -g ionic
Create app : ionic start appName blank
Goto app folder : cd appName
Add platform : ionic platform add android
Build your project : ionic build android
I hope it will work for you.

Related

Validation Error in running Hyperledger Caliper V0.4.2 with Fabric 2.1

When I have been running the Caliper V0.4.2 for measuring the benchmarks of Fabric 2.1.0 1.4.7, I got the below error
ValidationError: child "version" fails because ["version" must be one of [1.0]]. child "clients" fails because ["clients" is required]. child "channels" fails because ["channels" must be an object]. child "organizations" fails because ["organizations" must be an object]. child "orderers" fails because ["orderers" is required]. child "peers" fails because ["peers" is required]
at Object.exports.process (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hapi/joi/lib/errors.js:202:19)
at internals.Object._validateWithOptions (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hapi/joi/lib/types/any/index.js:763:31)
at module.exports.internals.Any.root.validate (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hapi/joi/lib/index.js:145:23)
at Function._validateTopLevel (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-fabric/lib/configValidator.js:208:26)
at Function.validateNetwork (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-fabric/lib/configValidator.js:58:25)
at new FabricConnector (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-fabric/lib/fabric-connector.js:107:25)
at CaliperEngine.connectorFactory [as adapterFactory] (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-fabric/lib/connectorFactory.js:26:23)
at CaliperEngine.run (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-core/lib/manager/caliper-engine.js:93:36)
at Function.handler (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-cli/lib/launch/lib/launchManager.js:62:43)
at Object.module.exports.handler (/home/gow/fabric-benchmarks/caliper-benchmarks/node_modules/#hyperledger/caliper-cli/lib/launch/launchManagerCommand.js:46:44)
isJoi: true,
name: 'ValidationError',
details:
[ { message: '"version" must be one of [1.0]',
path: [Array],
type: 'any.allowOnly',
context: [Object] },
{ message: '"clients" is required',
path: [Array],
type: 'any.required',
context: [Object] },
{ message: '"channels" must be an object',
path: [Array],
type: 'object.base',
context: [Object] },
{ message: '"organizations" must be an object',
path: [Array],
type: 'object.base',
context: [Object] },
{ message: '"orderers" is required',
path: [Array],
type: 'any.required',
context: [Object] },
{ message: '"peers" is required',
path: [Array],
type: 'any.required',
context: [Object] } ],
_object:
{ name: 'Caliper Benchmarks',
version: '2.1.0',
caliper: { blockchain: 'fabric' },
channels: [ [Object] ],
organizations: [ [Object] ] },
annotate: [Function] }
Command that I run are,
npm init -y
npm install --only=prod #hyperledger/caliper-cli#0.4.0
npx caliper bind --caliper-bind-sut fabric:2.1
./network.sh deployCC -ccn simple -ccp ../../caliper-benchmarks/src/fabric/scenario/simple/node -ccl javascript
npx caliper launch manager --caliper-workspace ./ --caliper-networkconfig networks/fabric/test-network.yaml --caliper-benchconfig benchmarks/scenario/simple/config.yaml --caliper-flow-only-test --caliper-fabric-gateway-enabled
Hyperledger network creation, channel creation and Chaincode deployment all were successful.
How to solve this error?
Looks like you are using the main branch of caliper-benchmarks. I would suggest you https://github.com/hyperledger/caliper-benchmarks/blob/main/networks/fabric/README.md
From what you have posted, you should use the latest available version of caliper which is 0.4.2, not 0.4.0. To do so the command you should issue is
npm install --only=prod #hyperledger/caliper-cli
You should bind to the latest 2.2 sdk (don't bind to 2.1 as fabric doesn't support 2.1). Note this is selecting the version of the sdk used to interact with a fabric network, not the version of the fabric network you are using. 2.2 will work with a fabric 2.2 and later 2.x versions
npx caliper bind --caliper-bind-sut fabric:2.2
Finally it looks like you tried to change the version number in the network configuration file. Don't change the version (it must be 2.0.0) as it refers to the version of the network configuration file and not the version of fabric you want to test
As you look to be using test-network, depending on which branch of fabric-samples you are using defines the version of fabric. The main branch tests the latest version of fabric which should have no problems.

node-Web3 = require('web3') displays function code instead of executing

I'm working with a -great- tutorial on Blockchain-Ethereum ( Full Stack Hello World Voting Ethereum Dapp Tutorial  ) .
I followed all the steps but when i try to execute some code with the node command I get displayed the function code instead of being executed as it should .
To be more specific , in the :
$ node
> Web3 = require('web3')
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
I get as result :
> Web3 = require('web3')
{ [Function: Web3]
version: '1.0.0-beta.36',
utils:
{ _fireError: [Function: _fireError],
_jsonInterfaceMethodToString: [Function: _jsonInterfaceMethodToString],
_flattenTypes: [Function: _flattenTypes],
randomHex: [Function: randomHex],
_:
{ [Function: _]
_: [Circular],
VERSION: '1.8.3',
iteratee: [Function],
forEach: [Function],
...............................
{ WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider] } }
the same happens with the second command as well . I already asked at the tutorial's comment section , but any advise is more than welcome .
Thanks!

Get all network interfaces with node

How would I get all network interfaces and their IP address, mac addresses, state, and it's master interface.
os.networkInterfaces() won't work, because it doesn't report interfaces that are down, or don't have IP addresses, and it doesn't return their state (UP/DOWN/etc) or their master interface.
var shell = require('shelljs');
var interfaceCard = shell.ls('/sys/class/net');
this interfaceCard has list of all network interfaces
output will be
[ 'eth0',
'eth1',
'lo',
**stdout: 'eth0\neth1\nlo\n',**
stderr: null,
code: 0,
cat: [Function: bound ],
exec: [Function: bound ],
grep: [Function: bound ],
head: [Function: bound ],
sed: [Function: bound ],
sort: [Function: bound ],
tail: [Function: bound ],
to: [Function: bound ],
toEnd: [Function: bound ],
uniq: [Function: bound ] ]
interfaceCard=interfaceCard.**stdout**.split('\n');
interfaceCard = eth0, eth1, lo

meteor: How to list files and directories from the project root path?

I'm using Meteor 1.0.2.1 and I noticed that working with the filesystem is not as easy as I tought :p
I ended up installing the peerlibrary:fs package (https://atmospherejs.com/peerlibrary/fs) so that I now have access to the node.js "fs" module and now I'm trying to list the content of the public folder but as mentioned here:
Reading files from a directory inside a meteor app
the path now (with version 1) seems to be '../../../../../public'
var files = fs.readdirSync('../../../../../public');
But I assume this to be wrong.
Is there an alias to the project root folder?
Is it ok to use the peerlibrary:fs for this?
Thanks.
console.log of _meteor_bootstrap_ says(I removed personal content)
{ startupHooks:
[ [Function], [Function],
[Function], [Function],
[Function],
[Function],
[Function],
[Function],
[Function] ],
serverDir: 'my_path_to_serverDir',
configJson:
{ meteorRelease: 'METEOR#1.0.2',
clientPaths: { 'web.browser': '../web.browser/program.json' } } }
=> Started your app.
I did checked program.json in /home/user/app/.meteor/local/build/programs/web.browser/program.json
Part of it looks like that(I changed some personal data)
{
"path": "app/pathToImage/image.png",
"where": "client",
"type": "asset",
"cacheable": false,
"url": "/pathToimage/image.png",
"size": someSize,
"hash": "someHash"
},
On that i state there is no public folder in deployed state but you can get paths from program.json file and _meteor_bootstrap_.configJson.clientPaths gives object with path to it wich looks like this(paste from console.log):
{ 'web.browser': '../web.browser/program.json' }

Commander can't handle multiple command arguments

I have the following commander command with multiple arguments:
var program = require('commander');
program
.command('rename <id> [name]')
.action(function() {
console.log(arguments);
});
program.parse(process.argv);
Using the app yields the following result:
$ node app.js 1 "Hello"
{ '0': '1',
'1':
{ commands: [],
options: [],
_execs: [],
_args: [ [Object] ],
_name: 'rename',
parent:
{ commands: [Object],
options: [],
_execs: [],
_args: [],
_name: 'app',
Command: [Function: Command],
Option: [Function: Option],
_events: [Object],
rawArgs: [Object],
args: [Object] } } }
As you can see, the action receives the first argument (<id>) and program, but doesn't receives the second argument: [name].
I've tried:
Making [name] a required argument.
Passing the name unquoted to the tool from the command line.
Simplifying my real app into the tiny reproducible program above.
Using a variadic argument for name (rename <id> [name...]), but this results on both 1 and Hello to being assigned into the same array as the first parameter to action, defeating the purpose of having id.
What am I missing? Does commander only accepts one argument per command (doesn't looks so in the documentation)?
I think this was a bug in an old version of commander. This works now with commander#2.9.0.
I ran in to the same problems, and decided to use Caporal instead.
Here's an example from their docs on Creating a command:
When writing complex programs, you'll likely want to manage multiple commands. Use the .command() method to specify them:
program
// a first command
.command("my-command", "Optional command description used in help")
.argument(/* ... */)
.action(/* ... */)
// a second command
.command("sec-command", "...")
.option(/* ... */)
.action(/* ... */)

Resources