nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.63k stars 2.36k forks source link

ng g app... Cannot read property 'toString' of null #1096

Closed jwright04 closed 5 years ago

jwright04 commented 5 years ago

I don't seem to see this exact issue here, but I create my angular project, then run

ng g app dashboard --routing -p=app --style=scss --d

I get the following prompts

? In which directory should the application be generated? apps
? Which Unit Test Runner would you like to use for the application? Karma [ https://karma-runner.github.io ]
? Which E2E Test Runner would you like to use for the application? Protractor [ https://www.protractortest.org ]
? Which tags would you like to add to the application? (used for linting) test

I end up with the error

Cannot read property 'toString' of null

I'm obviously doing something wrong, any suggestions?

Angular CLI: 7.3.3
Node: 9.9.0
OS: darwin x64
Angular: 7.2.6

@angular-devkit/architect         0.13.3
@angular-devkit/build-angular     0.13.3
@angular-devkit/build-optimizer   0.13.3
@angular-devkit/build-webpack     0.13.3
@angular-devkit/core              7.3.3
@angular-devkit/schematics        7.3.3
@angular/cli                      7.3.3
@ngtools/webpack                  7.3.3
@schematics/angular               7.3.3
@schematics/update                0.13.3
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.29.0

"@nrwl/nx": "7.6.0",
"@nrwl/schematics": "7.6.0",

Expected Behavior

Please describe the behavior you are expecting Create a new app called "dashboard" in "apps" directory

Current Behavior

What is the current behavior? Cannot read property 'toString' of null

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

ghost commented 5 years ago

I'm seeing this issue as well. Haven't used nx before, just trying to follow https://nrwl.io/nx/guide-nx-workspace as written.

$ ng --version Angular CLI: 7.3.0 Node: 10.15.1 OS: win32 x64 Angular: 7.2.6 ... typescript 3.2.2

@nrwl/schematics@7.6.0

$ create-nx-workspace workspace (completes fine) $ cd workspace $ ng g app example ? In which directory should the application be generated? example ? Would you like to add Angular routing? No ? Which Unit Test Runner would you like to use for the application? Jest [ https://jestjs.io ] ? Which E2E Test Runner would you like to use for the application? Cypress [ https://www.cypress.io ] ? Which tags would you like to add to the application? (used for linting) Path "/apps/example/example-e2e/tsconfig.e2e.json" does not exist.

$ ng g app example ? In which directory should the application be generated? example ? Would you like to add Angular routing? No ? Which Unit Test Runner would you like to use for the application? Karma [ https://karma-runner.github.io ] ? Which E2E Test Runner would you like to use for the application? Protractor [ https://www.protractortest.org ] ? Which tags would you like to add to the application? (used for linting) test Cannot read property 'toString' of null

stekosto commented 5 years ago

Exact same issue here.

Angular CLI: 7.3.3 Node: 10.10.0 OS: win32 x64 Angular: 7.2.6

Package Version

@angular-devkit/architect 0.13.3 @angular-devkit/build-angular 0.13.3 @angular-devkit/build-optimizer 0.13.3 @angular-devkit/build-webpack 0.13.3 @angular-devkit/core 7.3.3 @angular-devkit/schematics 7.3.3 @angular/cli 7.3.3 @ngtools/webpack 7.3.3 @schematics/angular 7.3.3 @schematics/update 0.13.3 rxjs 6.4.0 typescript 3.2.4 webpack 4.29.0

$ ng g app demo ? In which directory should the application be generated? demo ? Would you like to add Angular routing? Yes ? Which Unit Test Runner would you like to use for the application? Karma [ https://karma-runner.github.io ] ? Which E2E Test Runner would you like to use for the application? Protractor [ https://www.protractortest.org ] ? Which tags would you like to add to the application? (used for linting) lintTag Cannot read property 'toString' of null

zbigniewmotyka commented 5 years ago

It looks like a bug in newest version of schematic. It works when you downgrade it to previous version: npm install -g @angular/cli @nrwl/schematics@~7.5.2

Muromi-Rikka commented 5 years ago

+1

isaacplmann commented 5 years ago

You can also solve this issue by using @nrwl/schematics@7.6.1 and @angular/cli@7.3.1.

Another problem caused by @nrwl/schematics@7.6.1 and @angular/cli@7.3.3 is that you can't generate a lib.

ng generate @nrwl/schematics:library mylib

Path "/libs/mylib/src/lib/mylib.service.ts" does not exist.
FrozenPandaz commented 5 years ago

@isaacplmann is right, @angular/cli@7.3.3 has a breaking change with how applications and libraries are generated.

✅ A fix has been released in @nrwl/schematics@7.6.1 which fixes the issue for new workspaces. ✅ Update: @nrwl/schematics@7.6.2 has been released resolving the issue for updating workspaces. ⌛️ We are also working with the Angular CLI on the breaking change.

Sorry for the inconvenience. 😞

FrozenPandaz commented 5 years ago

I'm going to mark this as resolved form our end. We've rolled out @nrwl/schematics@7.2.2 which should not have this issue anymore. Let us know if you see anymore issues.

gund commented 5 years ago

Issue still persists with @nrwl/schematics@7.6.2: Cannot read property 'toString' of null

Also I'm getting different error messages if I pick different E2E frameworks:

Edit: Generation of libs also broken with exact error message posted by @isaacplmann.

Looks like a regression to me...

Angular CLI: 7.3.3
Node: 11.9.0
OS: darwin x64
Angular: 7.2.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.3
@angular-devkit/build-angular      0.13.3
@angular-devkit/build-ng-packagr   0.13.3
@angular-devkit/build-optimizer    0.13.3
@angular-devkit/build-webpack      0.13.3
@angular-devkit/core               7.3.3
@angular-devkit/schematics         7.3.3
@angular/cdk                       7.3.3
@angular/cli                       7.3.3
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.3.3
@schematics/angular                7.3.3
@schematics/update                 0.13.3
ng-packagr                         4.7.1
rxjs                               6.4.0
typescript                         3.2.4
webpack                            4.29.0
kklimczak commented 5 years ago

I noticed the same problem during generating library with config:

Angular CLI: 7.2.4
Node: 8.11.3
OS: linux x64
Angular: 7.2.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.2.4
@angular-devkit/schematics        7.2.4
@angular/cdk                      7.3.3
@angular/cli                      7.2.4
@angular/material                 7.3.3
@ngtools/webpack                  7.1.4
@schematics/angular               7.3.3
@schematics/update                0.12.4
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.23.1

I tried 7.5.1, 7.6.1, 7.6.2 versions of @nrwl/schematics.

spidermon commented 5 years ago

In our project this issue was reproducible with latest angular cli and nx. Cause of issue was @angular/pwa package or some of 14 derived dependencies. I didn't dig deep enough but workaround is to delete @angular/pwa. Angular CLI with nx working after that as expected.

mohyeid commented 5 years ago

I tried all combinations above, and none of them works. Always failing at the e2e step with above errors.

agusdutra commented 5 years ago

I was having this issue with ng generate app , without any extra config.

After updating schematics and angular cli it worked.

@nrwl/schematics@7.6.2
@angular/cli@7.3.5
gund commented 5 years ago

Can confirm in my project CLI works again after upgrading angular and NX libs.

github-actions[bot] commented 1 year ago

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.