npm / npm/cli

[BUG] Incorrect dependency version in mono repo

Open
#8,136 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

I originally posted this issue in Astro because I thought it was an Astro issue, but I think this is an npm issue.

Describe the Bug
In my mono repo using npm I have 2 apps:
apps/demo
apps/documentation

The documentation app uses astro with react, I followed the steps from the Astro documentation. This should use react version 19.
The demo app uses create react app with react version 17.

When I run the documentation app I get the error

Missing "./server.js" specifier in "react-dom" package

When I run npm ls react-dom in the root of my mono repo I get the following result showing astrojs/react is using react-dom version 17 instead of 19.

root
├─┬ demo@14.1.1 -> ./apps/demo
│ ├── react-dom@17.0.2
│ └─┬ react-router-dom@6.29.0
│   └── react-dom@17.0.2 deduped
└─┬ documentation@0.0.1 -> ./apps/documentation
  ├─┬ @astrojs/react@4.2.0
  │ └── react-dom@17.0.2 deduped
  └── react-dom@19.0.0

I added an overrides to my root package.json:

"overrides": {
    "@astrojs/react": {
      "react": "^19.0.0",
      "react-dom": "^19.0.0",
      "@types/react": "^19.0.10",
      "@types/react-dom": "^19.0.4"
    }
  }

Now when running npm ls react I get:

root
├─┬ demo@14.1.1 -> ./apps/demo
│ ├── react-dom@17.0.2 overridden
│ └─┬ react-router-dom@6.29.0
│   └── react-dom@17.0.2 deduped
└─┬ documentation@0.0.1 -> ./apps/documentation
  ├─┬ @astrojs/react@4.2.0 overridden
  │ └── react-dom@17.0.2 deduped invalid: "^19.0.0" from node_modules/@astrojs/react
  └── react-dom@19.0.0

None of this seem to solve the error. Any ideas?

Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-bqrrwddb?file=package.json

Note about the stackblitz demo. I wasn't able to fully reproduce this, I'm not getting the error but I do get unexpected react-dom version when running npm ls react-dom in the root:

my-monorepo@ /home/projects/github-bqrrwddb
+-- demo@0.1.0 -> ./apps/demo
| `-- react-dom@17.0.2
`-- documentation@0.0.1 -> ./apps/documentation
  +-- @astrojs/react@4.2.0
  | `-- react-dom@18.3.1
  `-- react-dom@19.0.0
Expected Behavior

Use the correct react version.

Steps To Reproduce
  1. https://stackblitz.com/edit/github-bqrrwddb?file=package.json
  2. npm ls react-dom
  3. See react-dom version is not as expected
Environment
  • npm: 10.9.2
  • Node.js: v22.14.0
  • OS Name: MacOS
  • System Model Name: Macbook Pro 2024

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz package.json and reproduce the workspace using npm 10.9.2 and Node.js v22.14.0. Run npm ls react-dom and compare the versions selected for demo and documentation; done means the expected React version is resolved for the documentation app without breaking the demo app.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, react
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.