Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm outdated in a project with workspaces can produce:
Package Current Wanted Latest Location Depended by
xxx 1.0.00 1.0.00 1.1.00 node_modules/xxx workspace1@npm:workspace1name@1.0.0
xxx 1.0.00 1.0.00 1.1.00 node_modules/xxx workspace2@npm:workspace2name@1.0.0
xxx 1.0.00 1.0.00 1.1.00 node_modules/xxx rootProject
...but when doing npm outdated --json, only details of the last dependent is shown:
{
"xxx": {
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"dependent": "rootProject",
"location": "../rootProject/node_modules/xxx"
}
Hence, seems like whatever reducer is producing the json is flattening to the last dependent, rather than providing a full list that would be available without --json.
To get around this, one must call npm outdated --json --workspace=xxx for each workspace, then consolidate the results. Presumably the --json option shouldn't produce less information than the tabular format?
Expected Behavior
Either the output needs to include an array per dependency:
{
"xxx": [
{
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"dependent": "workspace1",
"location": "../rootProject/node_modules/xxx"
},
{
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"dependent": "workspace2",
"location": "../rootProject/node_modules/xxx"
},
{
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"dependent": "rootProject",
"location": "../rootProject/node_modules/xxx"
}
]
}
..or if "dependent" isn't needed in the output as a key, just key a map by dependent:
{
"xxx": {
"rootProject": {
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"location": "../rootProject/node_modules/xxx"
},
"workspace1": {
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"location": "../rootProject/node_modules/xxx"
},
"workspace2": {
"current": "1.0.00",
"wanted": "1.0.00",
"latest": "1.1.00",
"location": "../rootProject/node_modules/xxx"
}
}
}
Steps To Reproduce
npm outdated --json with a project that includes workspaces (with or without the --workspaces flag)
Environment
- npm: 9.5.0
- Node.js: v18.16.1
- OS Name: Ventura 13.4.1
- System Model Name: Macbook Pro
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm outdatedin a project with workspaces can produce:...but when doing
npm outdated --json, only details of the last dependent is shown:{ "xxx": { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "dependent": "rootProject", "location": "../rootProject/node_modules/xxx" }Hence, seems like whatever reducer is producing the json is flattening to the last dependent, rather than providing a full list that would be available without
--json.To get around this, one must call
npm outdated --json --workspace=xxxfor each workspace, then consolidate the results. Presumably the--jsonoption shouldn't produce less information than the tabular format?Expected Behavior
Either the output needs to include an array per dependency:
{ "xxx": [ { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "dependent": "workspace1", "location": "../rootProject/node_modules/xxx" }, { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "dependent": "workspace2", "location": "../rootProject/node_modules/xxx" }, { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "dependent": "rootProject", "location": "../rootProject/node_modules/xxx" } ] }..or if "dependent" isn't needed in the output as a key, just key a map by dependent:
{ "xxx": { "rootProject": { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "location": "../rootProject/node_modules/xxx" }, "workspace1": { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "location": "../rootProject/node_modules/xxx" }, "workspace2": { "current": "1.0.00", "wanted": "1.0.00", "latest": "1.1.00", "location": "../rootProject/node_modules/xxx" } } }Steps To Reproduce
npm outdated --jsonwith a project that includesworkspaces(with or without the--workspacesflag)Environment