Usually, the tutorials show how to install angular/cli globally.
It happens that sometimes our environment has already a previous installation different from the new one we desire to use for a new project.
For instance, suppose that you’re working using the latest versions but you need to maintain an old project that was built using Angular 7.
In this case, it is required to install the Angular 7 locally, isolating it from your global environment configuration.
For instance, suppose that you’re working using the latest versions but you need to maintain an old project that was built using Angular 7.
In this case, it is required to install the Angular 7 locally, isolating it from your global environment configuration.
This example uses Angular 7 plus Bootstrap.
To use other versions, just switch the version in the commands used in the example.
To use other versions, just switch the version in the commands used in the example.
The recipe:
- Create a new folder for the new project.
mkdir it4us_v7_demo
NOTE: Be really patient, the command will take some time to finish.
Take advantage to grab your coffee, or better two or three!! .Depending on your environment security configuration, a good idea is to turn off the antivirus real-time scanning for some minutes to agile the installation.
. - Go to the new folder.
cd it4us_v7_demo
. - Create the local Angular 7 env plus the new project in just one command.
npx -p @angular/cli@7.3.9 ng new it4us-a7—In this example, I’ve made the choices “yes for adding Angular Routing” and “CSS” option.
As expected, you shall have deprecated packages since it is an old version.
.
. - The final structure you get for the project.Notice that it was created a root directory for the project named “it4us_v7_demo”.Three reasons for that.
The first one is that the “ng new” command requires project names following its pattern, otherwise the command may refuse to run, returning an error message.
A second reason it is a good idea to detach the root name from the project name because you get the freedom to choose a different name to make it more semantic.
Eventually, the third reason is that you have an upper level above the angular project to keep stuff that shall not be inside the angular project itself.This is it, what you get:
.
. - Now, under the it4us-a7 folder you may use the usual commands to get your server up and running.
For instance:
ng build
or
ng serve
Brazilian system analyst graduated by UNESA (University Estácio de Sá – Rio de Janeiro). Geek by heart.