Skip to content
Latchkey

Nx "enforce-module-boundaries" lint violation in CI

The @nx/enforce-module-boundaries ESLint rule blocks imports that violate your project tag constraints (for example a scope:feature importing a scope:app). CI runs lint and fails on the forbidden import.

What this error means

ESLint fails in CI with an @nx/enforce-module-boundaries error naming the source and target tags and the disallowed import.

Nx
error  A project tagged with "scope:shared" can only depend on libs tagged with
"scope:shared". Violation: importing "@app/feature-x"  @nx/enforce-module-boundaries

Common causes

An import breaks a tag constraint

The rule's depConstraints forbid this source tag from depending on the target tag, so the import is a violation.

A missing or wrong tag on a project

A project without the right tags falls outside the allowed set, so an otherwise valid import is flagged.

How to fix it

Fix the import or the constraint

  1. Read the source and target tags in the error.
  2. Either move the code so the import is allowed, or widen depConstraints if the dependency is intentional.
  3. Re-run lint to confirm the boundary passes.
.eslintrc.json
"depConstraints": [
  { "sourceTag": "scope:shared", "onlyDependOnLibsWithTags": ["scope:shared"] }
]

Tag the project correctly

Add the right tags in project.json so the import falls within an allowed relationship.

project.json
{ "name": "feature-x", "tags": ["scope:feature", "type:feature"] }

How to prevent it

  • Tag every project so boundary rules apply consistently.
  • Keep depConstraints aligned with your intended architecture.
  • Run the boundaries lint locally before pushing.

Frequently asked questions

What causes ""enforce-module-boundaries""?
The rule's depConstraints forbid this source tag from depending on the target tag, so the import is a violation.
How do I fix "enforce-module-boundaries"?
Fix the import or the constraint

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card