Closed mooragor closed 1 year ago
Version 2 of the angular.json/workspace.json only works with the nx cli.
Do you still have the postinstall script that does decorate-angular-cli.js
or something similar to that?
Because of the angular.json file in the workspace, we always default to use the ng command, and if the decorate-angular-cli script is used, the ng command basically becomes nx under the hood.
You can try running the nx repair
command to see if it fixes things. Or rename the angular.json file to workspace.json and don't use the ng command.
There is a 'decorate-angular-cli.js' file in the NX folder. I can see something in that saying 'symlinkNgCLItoNxCLI();' I'm not sure if that was actually run at any stage in my environment - do you know how I would/should do that?
I tried 'npx nx repair' which looks like it added a schema to many of the project.json files, but it hasn't helped with ng being run. "$schema": "../../node_modules/nx/schemas/project-schema.json",
the decorate-angular-cli.js script should be run in a postinstall in the package.json like this: https://github.com/nrwl/nx-examples/blob/187bbad0ac064257aa11d32dfe01d481f73c7ee6/package.json#L26
It does look like that's in there. Maybe I've just mucked something up with the various 'npm i' and 'npm ci' I've run in the past.
"postinstall": "node tools/scripts/ngx-bootstrap-patch.js && node ./decorate-angular-cli.js && ngcc --properties es2020 browser module main && npm run update:publishable:deps",
Tried running the decorate script manually and it says:
PS C:\Users\xxx\workspaces\xxx\Nx> node ./decorate-angular-cli.js Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.
But it does look like @nrwl/workspace is installed - I can see the folder there under node_modules.
PS - thank you hugely for all this help - it is really really appreciated!
Remove your node_modules folder and do npm install
locally. Without any other flags
Have tried that, it again whinged about @nrwl/workspace not being installed, so what I have done is just manually do the rename/link by replacing the ng commands with copies of the nx commands under node_modules/.bin. All now working!
Thank you ever so much for your assistance!
Current Behavior
When I use the Nx console in VSCode to run 'lint' on my code, it generates the following:
If run the same commands on the command line myself, but substitute 'nx' for 'ng', the command works.
The angular.json file in the Nx folder does say in it it's ' "version": 2 '
Could the ng that's being used somehow be at a different version from nx?
Environment
Nx Console version:
v17.32.0
VSCode version: Version: 1.76.2 (user setup) Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884 Date: 2023-03-14T17:55:54.936Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.19044 Sandboxed: No