nx
nx copied to clipboard
Nx should warn / refuse to run when there is a version mismatch between @nx packages
- [ ] I'd be willing to implement this feature (contributing guide)
Description
If there are conflicting versions of @nx
packages installed, Nx should either log a warning on every command executed, or refuse to run at all.
eg. if I accidentally have @nx/js: 16.3
and @nx/node:15.4
installed for example, there should be a warning.
Motivation
I've experienced countless hard-to-debug issues when using Nx while @nx
package versions mismatched. It causes all kinds of weird problems to occur in the internals, making it really difficult to distinguish a bug in Nx from a configuration issue from a version mismatch problem.
Version mismatches can occur for a variety of reasons. For example, I had a version mismatch with Nx due to using an old version of lerna
(which depends on an old version of Nx). Since lerna
isn't managed by nx migrate
, I ended up with two versions after performing a migration.
I've also had cases where team members inadvertently used a newer version of a particular package when they were adding it for the first time. This is easy to do by accident with yarn add @nx/some-package
for example.
This would be a great QoL improvement I think.
Suggested Implementation
It should be possible to use the package manager to figure this out. eg. with yarn why
Alternate Implementations
Could also implement it within the Nx packages themselves when they are importing each other
If you run nx report
, it identifies if @nx/*
packages are misaligned and a command (nx migrate
) to remedy it. I recommend using nx report
as a common step when debugging issues.
I would be hesitant to have Nx not run at all when versions are mismatched and even a warning might be annoying.
Does this help remedy these types of issues?
I think it helps to remedy the issue once you know that's what the issue is, it's just that finding that out is usually really painful. It would be much nicer to at least warn when some series of packages being used as part of an Nx execution don't line up with versions. A warning being "annoying" is exactly the intention IMO, because it seems like Nx is never guaranteed to work correctly when the packages don't match. It's a situation that should be fixed by the end user ASAP
I'm going to go ahead and close this out. The additions to nx report should be seen when you go to file an issue since running it is required to accurately fill in the issue report, and there are some cases where an org may have a mismatch. Its not worth the added complexity to have the warning behind an env flag or verbose logging, and we don't want to increase the noisiness of the logs.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.