You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Details
When trying to import nestjs-cls, I get the following error
Cannot find module 'rxjs' from 'REDACTED/.yarn/__virtual__/nestjs-cls-virtual-c54616727a/0/cache/nestjs-cls-file-29ea52353d-10faf375e2.zip/node_modules/nestjs-cls/dist/src/lib/cls-initializers'
We use Yarn in PnP (Plug'n'Play) mode. I believe this is a bit more strict with module resolution, particularly around transitive dependencies. Since lib/cls-initializers/cls.interceptor.ts uses rxjs directly but this isn't declared as an explicit dependency of nestjs-cls (except in "dev" mode) I think Yarn is blocking this being imported. Same applies for reflect-metadata in lib/cls-initializers/use-cls.decorator.ts.
Fix
For 3.5.0, I think the fix would be adding rxjs and reflect-metadata to the root package.json in peerDependencies would fix this (not sure what version constraints). With the yarn workspace refactor, I think the same fix should instead be applied to packages/core/package.json
Workaround I was able to workaround this by downloading the v3.5.0 source code, making the above change to peerDependencies, and including this as a file: dependency in our package.json files. This works but isn't really practical to integrate into our build system, so this issue probably blocks us using this package. See reply below for much better workaround using packageExtensions
N.B. thanks for the awesome package using AsyncLocalStorage, looking forward to being able to use it.
The text was updated successfully, but these errors were encountered:
Yeah, that is a mistake, thank you for spotting this! The migration to yarn is not complete yet (the latest published version 3.5.0 is still based on the npm based structure), so that's why I haven't bumped into this earlier.
You can fix it in your repository right now (without altering nestjs-cls's source) by updating your .yarnrc.yml with this:
Overview
Add
rxjs
andreflect-metadata
topeerDependencies
of (I think)packages/core/package.json
.Versions
Details
When trying to import
nestjs-cls
, I get the following errorWe use Yarn in PnP (Plug'n'Play) mode. I believe this is a bit more strict with module resolution, particularly around transitive dependencies. Since
lib/cls-initializers/cls.interceptor.ts
usesrxjs
directly but this isn't declared as an explicit dependency ofnestjs-cls
(except in "dev" mode) I think Yarn is blocking this being imported. Same applies forreflect-metadata
inlib/cls-initializers/use-cls.decorator.ts
.Fix
For 3.5.0, I think the fix would be adding
rxjs
andreflect-metadata
to the rootpackage.json
inpeerDependencies
would fix this (not sure what version constraints). With the yarn workspace refactor, I think the same fix should instead be applied topackages/core/package.json
Workaround
I was able to workaround this by downloading the v3.5.0 source code, making the above change toSee reply below for much better workaround usingpeerDependencies
, and including this as afile:
dependency in ourpackage.json
files. This works but isn't really practical to integrate into our build system, so this issue probably blocks us using this package.packageExtensions
N.B. thanks for the awesome package using AsyncLocalStorage, looking forward to being able to use it.
The text was updated successfully, but these errors were encountered: