I am creating a new Angular project and would like all the Angular dependencies to be from the stable 7th version. However, it seems that while running the ng new app
command the Angular always fetches the latest version. My package.json shows all the angular packages like core, animations etc from ~8.0.0
.
I know that I can modify the package.json and set these dependencies to be fetched as per the semantic 7.x.x, but I would rather want it to be done automatically so that I do not run a chance of mis-matching any peer dependencies.
So, Is there a way that we can tell the CLI to fetch a particular angular version and all the dependencies according to that angular version.
EDIT: I have already tried insatlling @angular/[email protected]. Even after doing this if I run ng new app, my depencies are fetched as per the 8th version
ng updatelink To update to the next beta or pre-release version, use the --next=true option. To update from one major version to another, use the format ng update @angular/cli@^<major_version> @angular/core@^<major_version> .
The ng new command creates an Angular workspace folder and generates a new application skeleton. A workspace can contain multiple applications and libraries. The initial application created by the ng new command is at the top level of the workspace.
It can be done by using npx command that downloads and runs the package without installing it.
For example, npx @angular/cli@9 new my-project
creates a new folder my-project
in the current folder and puts a new project here using angular version 9. The local version of @angular/cli
in this case will be the same as used in npx
command so you can just continue working.
The syntax of the command is as follows npx @angular/cli@<package version> new <project-name>
.
There is no way to tell Angular CLI the specific Angular version you want to install. Instead, you can switch to another version of the Angular CLI and then create Angular project.
Run these commands first:
npm uninstall -g @angular/cli
npm install -g @angular/[email protected]
After it is installed, you can run:
ng new angular7
This will create your Angular 7 project with correct dependencies:
"@angular/animations": "~7.1.0",
"@angular/common": "~7.1.0",
"@angular/compiler": "~7.1.0",
"@angular/core": "~7.1.0",
"@angular/forms": "~7.1.0"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With