jsverse / transloco

🚀 😍 The internationalization (i18n) library for Angular
https://jsverse.github.io/transloco/
MIT License
2.01k stars 195 forks source link

Bug: No defaultProject in angular.json results in unreadable projectType property #504

Open mattgek opened 3 years ago

mattgek commented 3 years ago

Current behavior

Executing ng add @ngneat/transloco in an Angular or an Nrwl Nx Angular were angular.json doesn't have a defaultProject value assigned results in error Cannot read property 'projectType' of undefined

Expected behavior

A clear message that project is required in that case.

Minimal reproduction of the problem with instructions

Screenshots

Screen Shot 2021-09-17 at 12 39 44 Screen Shot 2021-09-17 at 12 40 58

Environment

- Transloco version: 2.23.2
- Angular version: 12.2.2

For Tooling issues:

- Node version: 16.1.0
- Platform:  Mac
### Contribution I would like to make a pull request for this feature: [x ] Yes! 🚀
shaharkazaz commented 3 years ago

@mattgek Waiting for your PR on this 🙂 I think that in case that a default project doesn't exists, prompt a list selection input so the user can select a project from the existing projects.

mattgek commented 3 years ago

@shaharkazaz maybe a stupid question but you have 4 different branches master, V2, V3 and V12. I assume V3 won't be the branch I need but from which branch do I need to create a new one? I saw master is still on angular 7 and v12 on the latest so I assume v12 is the correct one? Can you confirm?

shaharkazaz commented 3 years ago

@mattgek Please create a branch from master. I'm currently in the middle of upgrading our entire infrastructure. v3 includes all the upgrades (including Angular v12) but it will take a couple more days until it's merged.

shaharkazaz commented 2 years ago

@mattgek Do you still plan to create the PR for this issue? 🙂

raphaelzulliger commented 2 years ago

To probably help others who google and to put some weight on this: I was hit by this situation as well

The package @ngneat/transloco@4.1.1 will be installed and executed.
Would you like to proceed? Yes
✔ Packages successfully installed.
? 🌍 Which languages do you need? en,de
? 🚀 Are you working with server side rendering? No
Cannot read property 'projectType' of undefined

I'm using Angular 14. To circumvent this issue, I temporarily added

{
  ...
  "defaultProject": "xyz"
}

to my angular.json

Badisi commented 2 years ago

I also faced this error a few months ago as I'm authoring a bunch of schematics.

I explained why and the solution in the tip section here : ngx-schematics-utilities#usage

I will create a PR for that 😉