Reputation: 2594
Following some other answer I am trying to retrieve values from package.json
.
With "preload" feature I hope to do it like this:
echo 'console.log(???.name)' | node -r package.json
But the ???
bit is missing. What could it be in this case?
Thanks.
Upvotes: 1
Views: 97
Reputation: 187
You can try
var package = require('./package.json');
for (var i in package) {
if (typeof package[i] === 'object' && package[i].hasOwnProperty("name"))
console.log(package[i].name)
}
Upvotes: 1