1

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.

Community
  • 1
  • 1
Roman Saveljev
  • 2,544
  • 1
  • 21
  • 20

1 Answers1

1

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)
}
Van-Duyet Le
  • 167
  • 1
  • 2
  • 6