The title is pretty self explanatory.
There is a large project that has been built with nx a couple of years ago, where nx console works.
however, when running the commands, it is attempting to run them doing npx ng...
instead of npx nx...
as a result, since we are using angular 14 and nx 14, most of the commands don't work (like creating a new component, or a new library, or running lint or tests) because my angular.json file is version 2 (instead of v1 as expected by Angular's ng CLI)
The error I keep getting is
Invalid format version detected - Expected:[ 1 ] Found: [ 2 ]
After trying to generate a demo project to post here and answer the comment posted in my question, I realized that by default NX
seems to use the ng
command runner for most of the generator commands.
Upon reading thoroughly their documentation, I fixated in the fact that the nx
CLI decorates ng
, making nx
and ng
interchangeable.
Then I remembered not long ago while cleaning up the package.json
file, I removed the decorate-angular-cli.js
file from the root of my project, along with the postinstall command.
For reference:
if you generate any angular nx project, you'll get a file named decorate-angular-cli.js in the root of your project folder, and a postinstall script in your package.json that loks like this:
"postinstall": "node ./decorate-angular-cli.js"
So for me, restoring the file and the postinstall command did the trick.
It did not make nx console
use nx
instead of ng
, but instead it made the ng
commands run as if they were nx
(bc nx
and ng
are in fact interchangeable, only after running the contents of the file decorate-angular-cli.js
)
Edit: thx @Andrew Allen for pointing me in the right direction with your comment.