ng generate store AppState --root --module app.module.ts 错误
Posted
技术标签:
【中文标题】ng generate store AppState --root --module app.module.ts 错误【英文标题】:ng generate store AppState --root --module app.module.ts error 【发布时间】:2021-04-24 09:12:57 【问题描述】:执行以下命令时出现错误。
ng generate store AppState --root --module app.module.ts
我收到了这个错误
无法读取未定义的属性“根”
ngrx/store packages 是我最后安装的。
我的 packages.json 是:
"name": "hrm-crm-app",
"version": "0.0.0",
"scripts":
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-testing": "ng build -c testing",
"deploy-testing": "npm run build-testing && copy src\\app.test.yaml dist\\app\\app.yaml && gcloud app deploy dist\\app\\app.yaml"
,
"private": true,
"dependencies":
"@angular/animations": "~10.2.0",
"@angular/cdk": "^11.0.3",
"@angular/common": "~10.2.0",
"@angular/compiler": "^10.2.4",
"@angular/core": "~10.2.0",
"@angular/forms": "~10.2.0",
"@angular/platform-browser": "~10.2.0",
"@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0",
"@auth0/auth0-angular": "^1.3.1",
"@fortawesome/angular-fontawesome": "^0.7.0",
"@fortawesome/fontawesome-free": "^5.15.1",
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-brands-svg-icons": "^5.13.0",
"@fortawesome/free-regular-svg-icons": "^5.13.0",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "^10.1.2",
"@ngrx/store": "^10.1.2",
"@ngrx/store-devtools": "^10.1.2",
"bootstrap": "^4.5.3",
"primeflex": "^2.0.0",
"primeicons": "^4.1.0",
"primeng": "^11.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
,
"devDependencies":
"@angular-devkit/build-angular": "~0.1002.0",
"@angular/cli": "~10.2.0",
"@angular/compiler-cli": "~10.2.0",
"@ngrx/schematics": "^10.1.2",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
【问题讨论】:
【参考方案1】:您需要使用 @ngrx/schematics 命令前缀才能使其工作。在安装 @ngrx/schemics 时,它会要求默认集合。由于您没有默认集合,因此您可以使用以下命令生成商店。
ng generate @ngrx/schematics:store AppState --root --module app.module.ts
上述命令适用于 Angular 10+ 版本。
【讨论】:
以上是关于ng generate store AppState --root --module app.module.ts 错误的主要内容,如果未能解决你的问题,请参考以下文章
nrwl - ng generate 给出超出最大调用堆栈大小
发生未处理的异常:不支持:关键字“id”,使用“$id”作为模式 ID - Angular 13 中的“ng add @ngrx/store”
ng generate @angular/material:material-nav --name=main-nav 正确生成文件但它们不运行
是否可以使用单个 angular-cli 命令(如 ng generate component comp1、comp2、comp3)生成多个 Angular 组件?