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.
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)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.