Reputation: 465
Sadly we are, for several reasons, not able to use the angular 12 version, therefore we do not want to use the current versions of ng and nrwl.
I haven't found documentation about how to generate a project with a specific version of ng. It seems that it always uses the most corrent version. But we need to use an older version (^10.0.0
).
What I do is this:
yarn global add @nrwl/[email protected]
yarn create nx-workspace myProject --style=scss --preset=empty --nx-cloud=false --cli=angular
But this will use the 12.6.5
version:
"@angular/cli": "~12.1.0",
"@nrwl/tao": "12.6.5",
"@nrwl/cli": "12.6.5",
"@nrwl/workspace": "12.6.5",
"@types/node": "14.14.33",
"dotenv": "~10.0.0",
"ts-node": "~9.1.1",
"typescript": "~4.3.5",
"prettier": "^2.3.1"
I like to avoid all ^12 versions and get instead the ^10 versions of these libraries.
When I try (I am not sure if this is correct syntax): yarn create [email protected] myProject --style=scss --preset=empty --nx-cloud=false --cli=angular
it does not succed.
I get an error, like:
success Installed "[email protected]" with binaries:
- create-nx-workspace
/bin/sh: /usr/local/bin/[email protected]: No such file or directory
error Command failed.
If anybody could tell me how to execute a create nx-workspace command with a specific version, I would be thankfull.
Upvotes: 1
Views: 2258
Reputation: 1197
As others are suggesting, in order to generate angular with specific versions (lets say v11 or v8) you would have to first uninstall the global version you have installed.
I'll add it with npm examples as this is what I know; if yarn examples are provided I can update the answer at a later time.
npm uninstall -g @angular/cli
Next you would want to find the particular released version and install that
npm install -g @angular/[email protected]
from this point on your global CLI reference will be the installed version.
Bonus tip, if you're working with many projects that run on different versions of angular you can target the ng
of the node_modules folder via a command like npm run-script ng XYZ
.
Upvotes: 0
Reputation: 3076
According to the docs, the command yarn create nx-workspace
will always install latest create-nx-workspace and run its bin. This is why you're always seeing it install version 12.x.
Instead, you can split up and perform these steps manually. Note that we're running the global bin directly, not using yarn create
in this case:
yarn global add create-nx-workspace@^10.0.0
create-nx-workspace myProject --style=scss --preset=empty --nx-cloud=false --cli=angular
Upvotes: 1