The file is not under 'rootDir' when building
See original GitHub issueCurrent Behavior
When building, an error gets thrown:
rpt2: options error TS6059: File 'path-to-project/libs/ui/utils/setup-tests-after-env.ts' is not under 'rootDir' 'path-to-project/libs/ui/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Root file specified for compilation
rpt2: options error TS6059: File 'path-to-project/libs/ui/utils/ui-test-utils.tsx' is not under 'rootDir' 'path-to-project/libs/ui/src'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Root file specified for compilation
This is my setup.
path-to-project/libs/ui/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"types": ["node", "jest"]
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
]
}
path-to-project/libs/ui/tsconfig.spec.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs"
},
"include": [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/*.d.ts",
"./utils/setup-tests-after-env.ts"
]
}
path-to-project/tsconfig.base.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowJs": false,
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
"paths": {
...
},
"plugins": [
{
"name": "typescript-styled-plugin"
}
]
},
"exclude": ["node_modules", "tmp", "dist"]
}
path-to-project/libs/ui/utils/setup-tests-after-env.ts
import '@testing-library/jest-dom';
Based on other suggestions, I am not sure how to check if some libraries are publishable/buildable. I believe I have not used any of those two options when building these apps/libraries.
Expected Behavior
The error shouldn’t be happening.
Environment
Node : 14.15.4 OS : win32 x64 yarn : 2.4.2
nx : 11.1.1 @nrwl/angular : Not Found @nrwl/cli : 12.1.1 @nrwl/cypress : 12.1.1 @nrwl/devkit : 12.1.1 @nrwl/eslint-plugin-nx : 12.1.1 @nrwl/express : Not Found @nrwl/jest : 12.1.1 @nrwl/linter : 12.1.1 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : 12.1.1 @nrwl/schematics : 8.12.11 @nrwl/tao : 12.1.1 @nrwl/web : 12.1.1 @nrwl/workspace : 12.1.1 @nrwl/storybook : 12.1.1 @nrwl/gatsby : Not Found typescript : 4.3.2
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:17 (2 by maintainers)
I also encountered this problem while building a library.
The fix for me was updating the
package.json
. Apparently the package name has to match the tsconfig path name / the import path (nx generate @nrwl/node:library --importPath
)i also encountered this problem…
it was killing me… i couldn’t figure out why nx didn’t build right… it was giving me tons of errors about one of my referenced project @scope1/lib2 and all of its .ts files being outside the project that referenced it… i also noticed that the dep-graph had @scope1/lib2 but there was no dependency arrow from the referencing library…
i found this fix:
rm -rf node_modules/.cache
i’m guessing nx had something in the cache that was wrong… after deleting, the dep-graph finally showed the link properly and the build started working