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

v10 testing package is incompatible with yarn PnP due to cross-package relative import #12106

Closed
3 of 15 tasks
alexanderbartl opened this issue Jul 24, 2023 · 3 comments
Closed
3 of 15 tasks
Labels
needs triage This issue has not been looked into

Comments

@alexanderbartl
Copy link

alexanderbartl commented Jul 24, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When upgrading the @nestjs/* packages to version 10, everything works fine in projects using classic yarn. However, with yarn berry and plug'n'play, there no longer is a node_modules folder and we get the following typescript compiler error:

.yarn/__virtual__/@nestjs-testing-virtual-dc800f43e0/0/cache/@nestjs-testing-npm-10.0.0-3db06d0890-2309204562.zip/node_modules/@nestjs/testing/interfaces/override-module.interface.d.ts:1:34 - error TS2307: Cannot find module '../../core/interfaces/module-definition.interface' or its corresponding type declarations.
.yarn/__virtual__/@nestjs-testing-virtual-dc800f43e0/0/cache/@nestjs-testing-npm-10.0.0-3db06d0890-2309204562.zip/node_modules/@nestjs/testing/testing-module.builder.d.ts:4:34 - error TS2307: Cannot find module '../core/interfaces/module-definition.interface' or its corresponding type declarations.

Both files import from the @nestjs/core package via a relative path (import { ModuleDefinition } from '../../core/interfaces/module-definition.interface';) rather than via the package name, which only works with a node_modules folder.

Minimum reproduction code

https://github.com/alexanderbartl/nestjs-import-error-minimal

Steps to reproduce

  1. yarn set version berry
  2. Enable PnP
  3. Install v10 of nestjs
  4. Run tsc

Expected behavior

tsc compiles successfully.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

10.1.0

Packages versions

"@nestjs/testing": "10.1.0",

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

Note: I haven't checked if there are any other parts of the codebase using relative cross-package imports, but the ones in the testing package are the only ones reported in my projects.

@alexanderbartl alexanderbartl added the needs triage This issue has not been looked into label Jul 24, 2023
@kamilmysliwiec
Copy link
Member

Fixed in v10.1.1

@alexanderbartl
Copy link
Author

alexanderbartl commented Jul 24, 2023

That was fast, thanks, @kamilmysliwiec ! Unfortunately, I need to bother you again as the fix was only made in one of the two files mentioned above, testing-module.builder.d.ts is unchanged and continues to cause the problem.

Minimum repro above is updated to 10.1.1

@kamilmysliwiec
Copy link
Member

testing-module.builder.d.ts is an automatically generated file. Remove node_modules and reinstall your packages and you should be good to go.

@nestjs nestjs locked and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants