Bug(transloco): Cannot read properties of undefined (reading 'sourceRoot')
Is there an existing issue for this?
- [X] I have searched the existing issues
Which Transloco package(s) are the source of the bug?
Transloco
Is this a regression?
Yes
Current behavior
When installing in nx, I encounter the following error, first I install the package, then the add command.
I use monorepo, there are several libs in the packages directory, I want to install transloco in lib i18n
- npm i @jsverse/transloco
- nx g @jsverse/transloco:ng-add
nx g @jsverse/transloco:ng-add
NX Generating @jsverse/transloco:ng-add
โ ๐ Which languages do you need? ยท en, es
โ ๐ Are you working with server side rendering? (y/N) ยท false
TypeError: Cannot read properties of undefined (reading 'sourceRoot')
at C:\Users\Saeidi\source\ng-simorgh\node_modules\@jsverse\transloco\schematics\src\ng-add\index.js:38:36
at callRuleAsync (C:\Users\Saeidi\source\ng-simorgh\node_modules\@angular-devkit\schematics\src\rules\call.js:77:24)
at C:\Users\Saeidi\source\ng-simorgh\node_modules\@angular-devkit\schematics\src\rules\call.js:73:40
at Observable._subscribe (C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\observable\defer.js:8:31)
at Observable._trySubscribe (C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\Observable.js:41:25)
at C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\Observable.js:35:31
at Object.errorContext (C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\util\errorContext.js:22:9)
at Observable.subscribe (C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\Observable.js:26:24)
at C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\operators\map.js:9:16
at OperatorSubscriber.<anonymous> (C:\Users\Saeidi\source\ng-simorgh\node_modules\rxjs\dist\cjs\internal\util\lift.js:14:28)
NX Cannot read properties of undefined (reading 'sourceRoot')
Pass --verbose to see the stacktrace.
Expected behavior
Installation works
Please provide a link to a minimal reproduction of the bug, if you won't provide a link the issue won't be handled.
https://codesandbox.io/s/ngneat-transloco-kn52hs
Transloco Config
No response
Please provide the environment you discovered this bug in
Transloco: ^7.5.0
Angular: ~18.2.0
Node: v22.5.1
Package Manager: npm
OS: Windows
Browser
No response
Additional context
No response
I would like to make a pull request for this bug
Yes ๐
@saeidi-dev Hey ๐ How is the link you added reproducing the issue? Please add a reproduction repo. You are welcome to open a PR for the fix but I need to understand the scenario where this is happening ๐
I use monorepo, there are several libs in the packages directory, I want to install transloco in lib i18n @shaharkazaz
@saeidi-dev did you try specifiying the project?
nx structure
apps
-myapp
packages
-i18n // is lib
command:
nx g @jsverse/transloco:ng-add --project=i18n
@saeidi-dev Instead of describing the project, can you please create a reproduction repo? you are using nx this should take under 5 minutes to mimic your issue. This is important for debugging and reviewing the solution you want to make in your PR (if you wish to make one).