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

"this.tree.readText is not a function" error after updating nrwl/angular to 14.2.4 #10678

Closed
chioarub opened this issue Jun 10, 2022 · 12 comments
Assignees
Labels

Comments

@chioarub
Copy link

After installing "@nrwl/angular": "^14.2.4" I am not able to use the Nx Console or the CLI to generate Angular applications

Current Behavior

TypeError when generating Angular applications using Cli/NxConsole plugin

Expected Behavior

Generate Angular applications using Cli/NxConsole plugin

Steps to Reproduce

  1. generate nx workspace using npx create-nx-workspace test-workspace
  2. install nrwl Angular dependency npm install -D @nrwl/angular
  3. generate Angular application using cli or NxConsole plugin npx nx generate @nrwl/angular:application web-ui --style=scss --port=4200 --routing --standaloneConfig --no-interactive --dry-run

Failure Logs

run npx nx generate @nrwl/angular:application web-ui --style=scss --port=4200 --routing --standaloneConfig --no-interactive --dry-run

> NX Generating @nrwl/angular:application

TypeError: this.tree.readText is not a function at TreeWorkspaceHost.readFile (D:\Projects\Ts\Personal\test-workspace\node_modules\@schematics\angular\utility\workspace.js:23:26) at readJsonWorkspace (D:\Projects\Ts\Personal\test-workspace\node_modules\@schematics\angular\node_modules\@angular-devkit\core\src\workspace\json\reader.js:17:28) at Object.readWorkspace (D:\Projects\Ts\Personal\test-workspace\node_modules\@schematics\angular\node_modules\@angular-devkit\core\src\workspace\core.js:91:62) at async getWorkspace (D:\Projects\Ts\Personal\test-workspace\node_modules\@schematics\angular\utility\workspace.js:73:27) at async D:\Projects\Ts\Personal\test-workspace\node_modules\@schematics\angular\application\index.js:224:27

this.tree.readText is not a function

Environment

Windows 11
Node : 14.19.3
OS : win32 x64
npm : 6.14.17

nx : 14.2.4
@nrwl/angular : 14.2.4
@nrwl/cypress : 14.2.4
@nrwl/detox : Not Found
@nrwl/devkit : 14.2.4
@nrwl/eslint-plugin-nx : Not Found
@nrwl/express : Not Found
@nrwl/jest : 14.2.4
@nrwl/js : 14.2.4
@nrwl/linter : 14.2.4
@nrwl/nest : 14.2.4
@nrwl/next : Not Found
@nrwl/node : 14.2.4
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.2.4
@nrwl/web : Not Found
@nrwl/workspace : 14.2.4
typescript : 4.7.3

Community plugins:

@AgentEnder AgentEnder added the scope: angular Issues related to Angular support in Nx label Jun 10, 2022
@Coly010 Coly010 added the os: windows Issues that can only be replicated on Windows label Jun 10, 2022
@Coly010
Copy link
Contributor

Coly010 commented Jun 10, 2022

I can't reproduce this on MacOS with latest. I believe it might be an OS-specific issue for windows.

@Coly010
Copy link
Contributor

Coly010 commented Jun 10, 2022

Update, I cannot reproduce this on Windows either.

@chioarub Can you share the version of the Angular CLI that is within your workspace?
And also could you share the output of running npm ls @schematics/angular?

@Coly010 Coly010 added blocked: more info needed and removed os: windows Issues that can only be replicated on Windows labels Jun 10, 2022
@xMonkfish
Copy link

xMonkfish commented Jun 10, 2022

I am also experiencing this error since migrating to 14.2.4 in addition I also get a similar error when trying to create a lazy loaded module

`> Executing task: npx nx generate @schematics/angular:module test --module=app-routing --route=test2 --routing --no-interactive --dry-run <

NX Generating @schematics/angular:module

[NX] Angular devkit readJsonWorkspace fell back to Nx workspaces logic
TypeError: host.readText is not a function
at C:\repos\test-repo\testproj\node_modules@schematics\angular\module\index.js:84:33
at MergeMapSubscriber.project (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules@angular-devkit\schematics\src\rules\call.js:75:24)
at MergeMapSubscriber._tryNext (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\operators\mergeMap.js:67:27)
at MergeMapSubscriber._next (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\operators\mergeMap.js:57:18)
at MergeMapSubscriber.Subscriber.next (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\Subscriber.js:66:18)
at MergeMapSubscriber.notifyNext (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\operators\mergeMap.js:93:26)
at SimpleInnerSubscriber._next (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\innerSubscribe.js:27:21)
at SimpleInnerSubscriber.Subscriber.next (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\Subscriber.js:66:18)
at Observable._subscribe (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\util\subscribeToArray.js:5:20)
at Observable._trySubscribe (C:\repos\test-repo\testproj\node_modules@schematics\angular\node_modules\rxjs\internal\Observable.js:44:25)
host.readText is not a function
The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command npx nx generate @schematics/angular:module test --module=app-routing --route=test2 --routing --no-interactive --dry-run" terminated with exit code: 1.`

npm ls @schematics/angular Info
@angular/cli@14.0.1
@schematics/angular@14.0.1
@nrwl/angular@14.2.4
@schematics/angular@14.0.1 deduped

Environment

` Node : 16.13.2
OS : win32 x64
npm : 8.1.2

nx : 14.2.4
@nrwl/angular : 14.2.4
@nrwl/cypress : 14.2.4
@nrwl/detox : Not Found
@nrwl/devkit : 14.2.4
@nrwl/eslint-plugin-nx : 14.2.4
@nrwl/express : Not Found
@nrwl/jest : 14.2.4
@nrwl/js : Not Found
@nrwl/linter : 14.2.4
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.2.4
@nrwl/web : Not Found
@nrwl/workspace : 14.2.4
typescript : 4.7.3

Community plugins:
@ngrx/effects: 14.0.0-rc.0
@ngrx/router-store: 14.0.0-rc.0
@ngrx/store: 14.0.0-rc.0
@ngrx/store-devtools: 14.0.0-rc.0
eslint-plugin-ngrx: 2.1.2`

@chioarub
Copy link
Author

chioarub commented Jun 10, 2022

@Coly010 There is no Angular CLI installed in the workspace.
It will get installed once I generate the project, which at the moment I cannot do, due to the cli/NxConsole issue.
Output of npm ls @schematics/angular is
`-- @nrwl/angular@14.2.4

-- @schematics/angular@14.0.1`

@chioarub
Copy link
Author

Removing node_modules and reinstalling got it working. Issue can be closed.

@tunecino
Copy link

tunecino commented Jun 24, 2022

Same error here when running a dry run of npx nx generate @nrwl/angular:library.

Nx: 14.4.0-beta.1
Node: 18.4.0
npm: 8.13.1
OS: macOS 11.5.2 arm64 (M1)

Removing node_modules didn't fix it for me.
In my case, the solution was to add @angular-devkit/schematics as a dev dependency.
That fixed it.

@gib
Copy link

gib commented Jan 26, 2023

Thank you @tunecino, that's what I needed too

@Bhargav210592
Copy link

i already have @angular-devkit/schematics then also issue is not solved

@pdavie
Copy link

pdavie commented Feb 11, 2023

Adding @angular-devkit/schematics as a dev dependency fixed it for me also.

@Emkacf
Copy link

Emkacf commented Mar 15, 2023

@Bhargav210592 did you fix your issue? I have the same problem.

@webia1
Copy link

webia1 commented Apr 12, 2023

yarn add -D @angular-devkit/schematics 

@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 May 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests