Title: Cannot read property 'properties' of undefined when adding a lazy loaded module with ng generate · Issue #21397 · angular/angular-cli · GitHub
Open Graph Title: Cannot read property 'properties' of undefined when adding a lazy loaded module with ng generate · Issue #21397 · angular/angular-cli
X Title: Cannot read property 'properties' of undefined when adding a lazy loaded module with ng generate · Issue #21397 · angular/angular-cli
Description: 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description While attempting to find the module to add a lazy loaded route declaration to while generating a...
Open Graph Description: 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description While attempting to find the module to add a lazy loaded...
X Description: 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description While attempting to find the module to add a lazy loaded...
Opengraph URL: https://github.com/angular/angular-cli/issues/21397
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot read property 'properties' of undefined when adding a lazy loaded module with ng generate","articleBody":"# 🐞 Bug report\r\n\r\n### Command (mark with an `x`)\r\n\r\n\u003c!-- Can you pin-point the command or commands that are effected by this bug? --\u003e\r\n\u003c!-- ✍️edit: --\u003e\r\n\r\n- [ ] new\r\n- [ ] build\r\n- [ ] serve\r\n- [ ] test\r\n- [ ] e2e\r\n- [x] generate\r\n- [ ] add\r\n- [ ] update\r\n- [ ] lint\r\n- [ ] extract-i18n\r\n- [ ] run\r\n- [ ] config\r\n- [ ] help\r\n- [ ] version\r\n- [ ] doc\r\n\r\n### Description\r\n\r\nWhile attempting to find the module to add a lazy loaded route declaration to while generating a new lazy loaded module with option `--module=app`, `findModuleFromOptions` tries file candidates from least to most specific:\r\n\u003cpre\u003e\u003ccode\u003e\r\n[\r\n '/src/app/areas',\r\n '/src/app/areas/app.ts',\r\n '/src/app/areas/app.module.ts'\r\n]\r\n\u003c/code\u003e\u003c/pre\u003e\r\nIf both app.module.ts and app.ts exist, app.ts is returned. If that file does not include an @angular/core import, this leads to an \r\n`Cannot read property 'properties' of undefined` error down the line (node is undefined in `getMetadataField` in ast-utils).\r\n\r\n## 🔬 Minimal Reproduction\r\n\r\n- Create a new angular project using `ng new`.\r\n- Create an empty file `src/app/app.ts`\r\n- Call `ng g m foo --routing --route=foo --module=app`\r\n\r\n## 🔥 Exception or Error\r\n\r\n`Cannot read property 'properties' of undefined`\r\n\r\n## 🌍 Your Environment\r\n\r\n\u003cpre\u003e\u003ccode\u003e\r\nAngular CLI: 12.1.3\r\nNode: 12.18.3\r\nPackage Manager: npm 6.14.6\r\nOS: win32 x64\r\n\r\nAngular: 12.1.3\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... platform-browser, platform-browser-dynamic, router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1201.3\r\n@angular-devkit/build-angular 12.1.3\r\n@angular-devkit/core 12.1.3\r\n@angular-devkit/schematics 12.1.3\r\n@schematics/angular 12.1.3\r\nrxjs 6.6.7\r\ntypescript 4.3.5\r\n\u003c/code\u003e\u003c/pre\u003e\r\n\r\n## Workaround\r\n\r\nTo work around this issue, we can specify the module by file name, not module name:\r\n\r\n`ng g m foo --routing --route=foo --module=app.module.ts`\r\n\r\n","author":{"url":"https://github.com/mjamin","@type":"Person","name":"mjamin"},"datePublished":"2021-07-22T08:19:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/21397/angular-cli/issues/21397"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:001b12ba-410e-08d2-3987-a638c4fc8888 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C24A:115C7:AE67EB:E7C7E0:6A604969 |
| html-safe-nonce | af088a8ecba7159ace4ed6f53e7077f5864b7d39e1baae39f67821aaef52a534 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjRBOjExNUM3OkFFNjdFQjpFN0M3RTA6NkE2MDQ5NjkiLCJ2aXNpdG9yX2lkIjoiNTI5MTgyMDcxNjAzNTk1MDk1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d2f2939edfa26677a759efc7e771865b4d390e7087b477f0139a06ccb9a9db3e |
| hovercard-subject-tag | issue:950414123 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/21397/issue_layout |
| twitter:image | https://opengraph.githubassets.com/920e91ac1b1b3156670795ee71ca12e4ffb28e7edc6474505f63c8f0c21ed56a/angular/angular-cli/issues/21397 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/920e91ac1b1b3156670795ee71ca12e4ffb28e7edc6474505f63c8f0c21ed56a/angular/angular-cli/issues/21397 |
| og:image:alt | 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Description While attempting to find the module to add a lazy loaded... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mjamin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60da8c2a42fa2bbf5f7567474990ec467836a84444262a58e200fa91b7f3d2d0 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9824515e740d83d5eb82168a089b806ab0fe04a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width