Cannot use npm view command programmatically

Hi,
I need to use the npm view command programmatically to get a list of all available versions for a given package. Basically, I use it like this:

npm.load(() => {
  npm.commands.view([pkg, 'versions'], true, (err, data) => {
    console.log(data);
  });
});

Everything worked fine until npm 6.6.0. I read at the source code, and it looks like in case silent parameter is true (second parameter of npm.commands.view in the code below), nothing is returned (and if silent is false`, available versions are printed to stdout, and the result is returned). You can see it here: https://github.com/npm/cli/blob/bb8688d5aba998bcdbcd33ee0508dad8a9ec2278/lib/view.js#L187

My question is: why, if silent is true, nothing is returned? I would expect that nothing is printed to stdout, but the result should be returned, right?

If that’s a bug, I would be happy to submit a pull request. If that’s the expected behaviour, can you give me more explanation to understand?

PS: that is my first message on this support forum, I’m sorry if I made a mistake while posting this issue.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.