jsverse / transloco

๐Ÿš€ ๐Ÿ˜ The internationalization (i18n) library for Angular
https://jsverse.github.io/transloco/
MIT License
2.04k stars 197 forks source link

Bug(transloco): Cannot read properties of undefined (reading 'sourceRoot') #805

Open saeidi-dev opened 1 month ago

saeidi-dev commented 1 month ago

Is there an existing issue for this?

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

  1. npm i @jsverse/transloco
  2. 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 ๐Ÿš€

shaharkazaz commented 1 month ago

@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 ๐Ÿ‘

saeidi-dev commented 1 month ago

I use monorepo, there are several libs in the packages directory, I want to install transloco in lib i18n @shaharkazaz

shaharkazaz commented 1 month ago

@saeidi-dev did you try specifiying the project?

saeidi-dev commented 1 month ago

nx structure

apps
    -myapp
packages
    -i18n // is lib

command:

  nx g @jsverse/transloco:ng-add --project=i18n
shaharkazaz commented 1 month ago

@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).