Skip to content

Instantly share code, notes, and snippets.

@acburdine
Last active August 6, 2025 19:14
Show Gist options
  • Select an option

  • Save acburdine/ca28093a0772434cfc24119dffff5c14 to your computer and use it in GitHub Desktop.

Select an option

Save acburdine/ca28093a0772434cfc24119dffff5c14 to your computer and use it in GitHub Desktop.
NPM Workspaces Optional Peer Dep Resolution Bug

NPM Workspace Optional Peer Dependency Resolution Bug

With the above workspace setup/package configurations, the change in npm/cli#8431 specifically breaks installation of the platform-specific packages for lightningcss.

The lightningcss-darwin-arm64 et. al dependencies are all being flagged as "optional peer" dependencies, despite technically only being "optional" through the lightningcss dep. (verified via npm why lightningcss-darwin-arm64). What's interesting, though, is that lightningcss itself is correctly being flagged as a "dev" dependency (not optional, not peer).

The only fix I've been able to find for this is either installing lightningcss in the root package.json, or installing lightningcss as a dependency of services/b, even though it's unused.

{
"name": "@test-repro/a",
"version": "0.0.0",
"private": true,
"devDependencies": {
"lightningcss": "^1.30.1",
"vite": "^7.0.6"
}
}
[email protected] dev optional peer
node_modules/lightningcss-darwin-arm64
optional lightningcss-darwin-arm64@"1.30.1" from [email protected]
node_modules/lightningcss
peerOptional lightningcss@"^1.21.0" from [email protected]
node_modules/vite
dev vite@"^7.0.6" from @test-repro/[email protected]
apps/a
@test-repro/[email protected]
node_modules/@test-repro/a
workspace apps/a from the root project
dev vite@"^7.0.6" from @test-repro/[email protected]
services/b
@test-repro/[email protected]
node_modules/@test-repro/b
workspace services/b from the root project
dev lightningcss@"^1.30.1" from @test-repro/[email protected]
apps/a
@test-repro/[email protected]
node_modules/@test-repro/a
workspace apps/a from the root project
{
"name": "npm-bug-repro",
"version": "0.0.0",
"private": true,
"workspaces": [
"apps/*",
"services/*"
]
}
{
"name": "@test-repro/b",
"version": "0.0.0",
"private": true,
"devDependencies": {
"vite": "^7.0.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment