Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"nx g @nrwl/angular:ngrx" issues error in "create-nx-workspace --preset=angular-monorepo --standaloneApi=true --routing=true" #15119

Closed
LowArmour opened this issue Feb 19, 2023 · 3 comments · Fixed by #15221
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@LowArmour
Copy link

LowArmour commented Feb 19, 2023

Current Behavior

When generating the following:
nx g @nrwl/angular:ngrx --name=mystate --parent=apps/myapp/src/app/app.routes.ts --root=false --facade=true --verbose
in the following workspace:
npx create-nx-workspace@latest --name=myorg --appName=myapp --preset=angular-monorepo --style=scss --standaloneApi=true --routing=true --nxCloud=false
it issues the following error:
SyntaxError: Expected " " or "]" but "'" found. at Object.parse (/home/bt/test/myorg/node_modules/esquery/dist/esquery.min.js:1:29015) at Function.g [as parse] (/home/bt/test/myorg/node_modules/esquery/dist/esquery.min.js:1:34718) at Object.parse (/home/bt/test/myorg/node_modules/@phenomnomnominal/tsquery/dist/src/parse.js:9:34) at query (/home/bt/test/myorg/node_modules/@phenomnomnominal/tsquery/dist/src/query.js:11:39) at addProviderToRoute (/home/bt/test/myorg/node_modules/@nrwl/angular/src/utils/nx-devkit/route-utils.js:55:54) at addCommonImports (/home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/lib/add-imports-to-module.js:135:62) at addImportsToModule (/home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/lib/add-imports-to-module.js:157:26) at /home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/ngrx.js:15:42 at Generator.next (<anonymous>) at /home/bt/test/myorg/node_modules/tslib/tslib.js:167:75

Expected Behavior

One should be able to generate ngrx states using the nx schematics.

GitHub Repo

https://github.com/LowArmour/nx-ngrx-bug

Steps to Reproduce

  1. npx create-nx-workspace@latest --name=myorg --appName=myapp --preset=angular-monorepo --style=scss --standaloneApi=true --routing=true --nxCloud=false --verbose
  2. nx g @nrwl/angular:ngrx --name=mystate --parent=apps/myapp/src/app/app.routes.ts --root=false --facade=true
  3. The following error is issued:
    SyntaxError: Expected " " or "]" but "'" found. at Object.parse (/home/bt/test/myorg/node_modules/esquery/dist/esquery.min.js:1:29015) at Function.g [as parse] (/home/bt/test/myorg/node_modules/esquery/dist/esquery.min.js:1:34718) at Object.parse (/home/bt/test/myorg/node_modules/@phenomnomnominal/tsquery/dist/src/parse.js:9:34) at query (/home/bt/test/myorg/node_modules/@phenomnomnominal/tsquery/dist/src/query.js:11:39) at addProviderToRoute (/home/bt/test/myorg/node_modules/@nrwl/angular/src/utils/nx-devkit/route-utils.js:55:54) at addCommonImports (/home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/lib/add-imports-to-module.js:135:62) at addImportsToModule (/home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/lib/add-imports-to-module.js:157:26) at /home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/ngrx.js:15:42 at Generator.next (<anonymous>) at /home/bt/test/myorg/node_modules/tslib/tslib.js:167:75

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 18.13.0
   OS   : linux x64
   npm  : 9.5.0
   
   nx                      : 15.7.2
   @nrwl/jest              : 15.7.2
   @nrwl/linter            : 15.7.2
   @nrwl/workspace         : 15.7.2
   @nrwl/angular           : 15.7.2
   @nrwl/cli               : 15.7.2
   @nrwl/cypress           : 15.7.2
   @nrwl/devkit            : 15.7.2
   @nrwl/eslint-plugin-nx  : 15.7.2
   @nrwl/js                : 15.7.2
   @nrwl/tao               : 15.7.2
   @nrwl/webpack           : 15.7.2
   typescript              : 4.8.4

Failure Logs

`SyntaxError: Expected " " or "]" but "'" found.
    at Object.parse (/home/bt/test/myorg/node_modules/esquery/dist/esquery.min.js:1:29015)
    at Function.g [as parse] (/home/bt/test/myorg/node_modules/esquery/dist/esquery.min.js:1:34718)
    at Object.parse (/home/bt/test/myorg/node_modules/@phenomnomnominal/tsquery/dist/src/parse.js:9:34)
    at query (/home/bt/test/myorg/node_modules/@phenomnomnominal/tsquery/dist/src/query.js:11:39)
    at addProviderToRoute (/home/bt/test/myorg/node_modules/@nrwl/angular/src/utils/nx-devkit/route-utils.js:55:54)
    at addCommonImports (/home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/lib/add-imports-to-module.js:135:62)
    at addImportsToModule (/home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/lib/add-imports-to-module.js:157:26)
    at /home/bt/test/myorg/node_modules/@nrwl/angular/src/generators/ngrx/ngrx.js:15:42
    at Generator.next (<anonymous>)
    at /home/bt/test/myorg/node_modules/tslib/tslib.js:167:75`

Additional Information

Please see above.

@AgentEnder AgentEnder added the scope: angular Issues related to Angular support in Nx label Feb 21, 2023
@LowArmour
Copy link
Author

Hi, just wanted to add that I kind of hit a roadblock here. Is there any recommended way of generating/changing manually the files that nx g @nrwl/angular:ngrx generates/changes, just to have a workaround until a fix is issued?

@Coly010
Copy link
Contributor

Coly010 commented Feb 24, 2023

The workaround for now is to specify the route you want to attach the state to

nx g @nrwl/angular:ngrx --name=mystate --parent=apps/myapp/src/app/app.routes.ts --root=false --facade=true --route=''

I'll be creating a fix for it soon so that it can default --route='' correctly.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants