Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error TS6307 when building a project using @nx/esbuild or @nx/js:tsc with an imported library #30144

Open
2 of 4 tasks
mavliut-fozliev opened this issue Feb 23, 2025 · 0 comments
Assignees
Labels
scope: node Issues related to Node, Express, NestJS support for Nx type: bug

Comments

@mavliut-fozliev
Copy link

Current Behavior

Currently, when building an Nx project that imports a function from a library using either @nx/esbuild:esbuild or @nx/js:tsc, I encounter the following error:
error TS6307: File 'C:/Users/.../my-nx-monorepo/org/libs/mylibrary/src/index.ts' is not listed within the file list of project ''. Projects must list all files or use an 'include' pattern.
This indicates that the library file is not being recognized as part of the project during compilation, even though it is properly imported.

Expected Behavior

I expect the Nx project to successfully build without errors when using @nx/esbuild:esbuild or @nx/js:tsc, recognizing the imported library as part of the project. The build process should correctly include all necessary files from the library without requiring manual adjustments to the project's tsconfig.json or other configurations.

GitHub Repo

https://github.com/mavliut-fozliev/org

Steps to Reproduce

  1. create typescript/javascript monorepo using "creaete-nx-workspace"
  2. add node plugin "nx add @nx/node"
  3. generate app using "nx generate @nx/node:app apps/myapp"
  4. generate library "nx generate @nx/node:library libs/mylibrary"
  5. import relatively mylibrary function from libs/mylibrary 'import { mylibrary } from "../../../libs/mylibrary/src";'
  6. in the myapp tsconfig.app.json file add the path to the mylibrary tsconfig.lib.json for the composite build '"path": "../../libs/mylibrary/tsconfig.lib.json"'
  7. set "emitDeclarationOnly" property to "false"
  8. build myapp "nx build myapp"

The error occurs right here.

We will get a similar error if we use @nx/js:tsc as the executor instead of @nx/esbuild:esbuild

At the same time, if we build myapp using the command "tsc --build apps/myapp/tsconfig.app.json", then myapp and mylibrary are built without any errors

Nx Report

Node           : 22.7.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.8.2

nx (global)    : 20.0.6
nx             : 20.4.6
@nx/js         : 20.4.6
@nx/jest       : 20.4.6
@nx/eslint     : 20.4.6
@nx/workspace  : 20.4.6
@nx/devkit     : 20.4.6
@nx/esbuild    : 20.4.6
@nx/node       : 20.4.6
typescript     : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: node Issues related to Node, Express, NestJS support for Nx label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: node Issues related to Node, Express, NestJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants