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-boundariesCommon 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
- Read the source and target tags in the error.
- Either move the code so the import is allowed, or widen
depConstraintsif the dependency is intentional. - 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
depConstraintsaligned with your intended architecture. - Run the boundaries lint locally before pushing.
Related guides
Nx "Maximum call stack size exceeded" on project graph in CIFix Nx "Maximum call stack size exceeded" while building the project graph in CI - a circular dependency betw…
Nx "Running target failed" nonzero exit in CIFix Nx "Running target X for project Y failed" in CI - the underlying executor exited nonzero, so Nx marks th…
Nx invalid project.json schema in CIFix Nx invalid project.json in CI - a project configuration fails schema validation, so Nx cannot register th…