no-include-node-modules
Disallow include patterns that would match the node_modules directory.
Targeted pattern scopeโ
The include array in any tsconfig*.json file.
What this rule reportsโ
This rule reports include entries that explicitly target node_modules,
such as "node_modules", "node_modules/**", or glob patterns that resolve
to include it.
Why this rule existsโ
node_modules is excluded by TypeScript by default, and for good reason:
including it forces TypeScript to process thousands of source files from
installed packages โ dramatically increasing type-check time โ and may
introduce duplicate symbol declarations that conflict with the packages'
own .d.ts files.
TypeScript already reads declaration files from node_modules/@types and
package exports fields without node_modules being in include. Adding
it explicitly is never the right fix for type resolution problems and almost
always indicates a misconfiguration.
The auto-fixer removes the offending include entry.
โ Incorrectโ
{
"include": ["src", "node_modules/my-internal-package"]
}
TypeScript will process the source files of my-internal-package directly,
conflicting with its published type declarations.
โ Correctโ
{
"include": ["src"]
}
TypeScript resolves types for node_modules packages through their
declaration files automatically.
When not to use itโ
Disable this rule for monorepo workspaces that use a file: or symlinked
package and need to include source files from a sibling workspace package
โ though even in that case, using project references with composite: true
is the recommended approach.
Package documentationโ
Rule catalog ID: R010