Skip to content

[pull] latest from npm:latest#168

Merged
pull[bot] merged 2 commits into
NOUIY:latestfrom
npm:latest
May 15, 2026
Merged

[pull] latest from npm:latest#168
pull[bot] merged 2 commits into
NOUIY:latestfrom
npm:latest

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented May 15, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

ecanturk and others added 2 commits May 15, 2026 09:41
…e manifests (#9343)

### What

When using a proxy/upstream registry (e.g. Azure Artifacts), npm 11
writes lockfile entries for platform-specific optional dependencies
without `version`, `resolved`, or `integrity` fields. Subsequent `npm
ci` fails with `Invalid Version:` errors.

Example broken lockfile entry:
```json
"node_modules/@esbuild/aix-ppc64": {
  "optional": true
}
```

### Why

`#fetchManifest()` in `build-ideal-tree.js` fetches manifests for ALL
platform variants of optional dependencies. Proxy registries that
haven't cached packages for non-current platforms return incomplete
metadata (missing `version` field). npm creates a Node with empty
`pkg.version`, and `metaFromNode()` writes `{"optional": true}` to the
lockfile without version.

npm 10 never attempted to resolve non-current-platform variants, so this
only affects npm 11+.

### How

Two-layer defense:

1. **`build-ideal-tree.js` (`#nodeFromSpec`)**: When a registry manifest
lacks a `version` field, treat it as an `EINCOMPLETEMANIFEST` load
failure so that `#pruneFailedOptional()` marks it inert. Only applies to
`spec.registry` specs (not `file:` dependencies which may legitimately
omit version).

2. **`shrinkwrap.js` (`commit()`)**: Skip writing entries where the node
is optional, has no version, and is not the root. This acts as a
defense-in-depth layer.

### Testing

- Unit test added to `workspaces/arborist/test/shrinkwrap.js` —
simulates proxy registry scenario where an optional dep node has no
version
- All existing tests pass (`shrinkwrap.js` 45/45, `build-ideal-tree.js`
114/114)
- Manually verified with Azure Artifacts upstream proxy feed:
- Before fix: 46 broken lockfile entries (optional deps without version)
  - After fix: 0 broken entries
  - Output matches npm 10 behavior

Closes #9342

---------

Co-authored-by: Michael Smith <owlstronaut@github.com>
## Summary

Adds a small `package.json` example to the `optionalDependencies`
section of the package.json docs, so readers can see the expected shape
at a glance without parsing the surrounding prose.

Closes #9325.

## Test plan

- [x] `npm run build --workspace=docs` succeeds.
- [x] `npm test --workspace=docs` passes (100% coverage, lint,
template-oss-check).
- [x] Rendered HTML in `docs/output/configuring-npm/package-json.html`
shows the example as a `language-json` code block between the intro
paragraph and the "It is still your program's responsibility..."
paragraph; surrounding sections and TOC unchanged.
@pull pull Bot locked and limited conversation to collaborators May 15, 2026
@pull pull Bot added the ⤵️ pull label May 15, 2026
@pull pull Bot merged commit c97b39b into NOUIY:latest May 15, 2026
1 check was pending
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants