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: Cannot find module" in monorepo setup when dist folder has subfolders #2114

Closed
2 of 4 tasks
bindermuehle opened this issue Oct 6, 2022 · 1 comment
Closed
2 of 4 tasks

Comments

@bindermuehle
Copy link

bindermuehle commented Oct 6, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

when I try to build nest in my monorepo setup with the nestjs compilerOptions plugin loaded I get following error
Error: Cannot find module '../../../packages/math-helpers/dist/index'

The problem occurs when an type definition from a packaged internal module is used and there is more than one directory with *.ts in the nestjs app.

as a result the transpiled controller is placed in ./dist/src/ but the import assumes the file to be in the ./dist directory directly.
for example:
openapi.ApiResponse({ status: 200, type: require("../../../packages/math-helpers/dist/index").Me }),

Minimum reproduction code

https://github.com/bindermuehle/monorepo-issue

Steps to reproduce

  1. npm i
  2. npm run start:dev -w nest
  3. see error

Expected behavior

the transpiler plugin should set the correct import path and the nest app should start without any error

Package version

6.1.2

NestJS version

9.1.4

Node.js version

v16.13.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

@nestjs nestjs locked and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants