Alexander Mills
Alexander Mills

Reputation: 100070

Parse array written to stdout from `npm view x dependencies`

When I run the command

$ npm view JSONStream@^1.3.1 dependencies --json

I get:

[
  {
    "jsonparse": "^1.2.0",
    "through": ">=2.2.7 <3"
  },
  {
    "jsonparse": "^1.2.0",
    "through": ">=2.2.7 <3"
  }
]

my question is, what does each element in the array represent? I am guessing it represents a snapshot of the dependencies for each published version of JSONStream. However, the problem is I don't know which version each element is for! I would have thought it would have looked like this instead:

{
 "2.3.5": {
    "jsonparse": "^1.2.0",
    "through": ">=2.2.7 <3"
  },
  "2.3.6":{
    "jsonparse": "^1.2.0",
    "through": ">=2.2.7 <3"
  }
}

does anyone know how to figure out what each element in the array represents?

Upvotes: 1

Views: 115

Answers (1)

Patrick Roberts
Patrick Roberts

Reputation: 51886

You can use npm view JSONStream@^1.3.1 version --json to determine the respective version for each entry:

[
  "1.3.1",
  "1.3.2"
]

Protip, the argument after the package name is a field from the package.json. You can also omit the argument to see the entire metadata for each version.

Upvotes: 1

Related Questions