TS6059
error TS6059: File ‘
/root/project/packages/server/package.json
‘ is not under ‘rootDir’ ‘/root/project/packages/server/src
‘. ‘rootDir’ is expected to contain all source files.
Broken Code ❌
1 |
|
Fixed Code ✔️
When using require
then we can access files outside the specified root folder for input files (“rootDir” in “tsconfig.json”):
1 |
|
An even better solution would be changing the “rootDir” in your “tsconfig.json”, so that it includes the “package.json” file that you are trying to important. This may require you to also set “allowJs” to true
in your “tsconfig.json”.