The "File is not under 'rootDir'" error occurs when we try to import something from a file that is not located under the specified rootDir in tsconfig. json . To solve the error, move the file under the project's root directory or remove the rootDir setting from tsconfig. json .
Default: The longest common path of all non-declaration input files. If composite is set, the default is instead the directory containing the tsconfig. json file. When TypeScript compiles files, it keeps the same directory structure in the output directory as exists in the input directory.
rootDir
?rootDir
is set to a root folder, that contains all your source files. If not specified, TS will automatically choose a suitable parent folder of all inputs. rootDir
also determines the output directory.
My guess is you have an import
statement for logging.ts
somewhere in notifier-server
:
import {logger} from "@teros-cli/logging" // or similar
Then logging.ts
module will be automatically included by the compiler, regardless of include
and exclude
options in tsconfig.json
. One way to check all included files is tsc --listFiles
.
A tsconfig.json
file outside notifier-server
doesn't help here. The compiler picks up exactly one config per tsc
compilation and optionally pulls inherited configs. If it cannot find one in notifier-server
project root (where you started tsc
), only then the compiler searches upwards the parent directory chain, until a config is found.
One fix is to just remove "rootDir": "src"
from compiler options, so it gets set automatically. Caution: rootDir
will then consider both projects as inputs!
Alternative: You can add a separate logging.ts
module contained in notifier-server/src
project and drop the external import
.
Hope, that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With