Hi,
What does this command do? npm install @angular/cli@latest ( without -g)
Is it possible to install multiple angular-cli locally for each project on the same machine?
Currently we have 2 projects that using angular-cli.1.0.0.beta.24 and we are working on new project using latest version of angular-cli.
We don't want to spend time work update other 2 projects to work with [email protected].
We just want able to work on both new and old angular-cli.
thanks
Jdang
The global CLI will always use the CLI installed in your project, whichever version. So if you install globally with a new version but the project has a beta dependency (e.g.) then it will use the beta version of the CLI to perform actions on the project.
That is not what we see.
We installed version 1.0.0 globally.
We also install 1.0.0-beta.24 for one of the project locally.
Inside that project, we run: ng -v it shows angular-cli version 1.0.0.
We expect to show 1.0.0-beta.24
To run multiple different versions, which are local defined, in parallell is must have for modular development.
Lets consider the following scenario:
Team One has not touched code "A"-repo for long time, which was started with 0.8 angular-cli.
They continue to work on new code "B" repo with new cli-version 1.0.
Later they need a urgend hotfix on repo "A" like a bugfix.
How can they make sure, angular-cli is generating exact same code for prod in "A" repo, without downgrading to 0.8 cli ?
are there any solutions for this kind of problem and why was the ticket closed?
Yes, we have a solution for this problem.
Install angular-cli version globally that supports the old-application
then making sure the old application works.
Install newer angular-cli version globally .
Create a new app using newest angular-cli version and making sure it works.
Verify the step 1 still work.
Wow, what an elegant workflow, if you work on two projects in paralell ! irony
Just takes you around 5 minutes to reinstall every time.
David,
Our workflow allow to run more than one angular projects with different angular-cli at the same time with out reinstall.
Jdang
I see,
But all the versions have to be compatible to each other.
Well if all the versions have to be able to be compatible to each other then we should upgrade using a single latest version to make our life easier.
In our case, we are be able to run angular-cli-beta-24 and current latest version at the same time.
Even I face the same problem. one of my old projects is using angular-cli 1.0.0-beta.14 and I want to work on a new project which is on angular/cli (latest version). can anyone help me on how to switch version without reinstalling?
From https://stackoverflow.com/questions/42295591/angular-cli-lower-version-locally
In package.json make a script for ng
"scripts": {
"ng": "ng"
}
Calling "npm run-script ng build" will use the local version of the cli. It will work even if you haven't installed the cli globally.
Thanks darrhal. This also works for "npm run-script ng serve --open"
its Working fine, all version supported in latest one, but it will show some deprecated message, thats no problem
darrhal, thank you very much!!! It hepled me
One more idea, it might me useful for someone... It's possible to install certain version in parent folder. After that, ng new
command will use that version for creating a new project.
I like the idea of not installing/using global libraries (except of course node and npm). Admittedly, you could be running a vagrant box (or container) for each dev project, then it doesn't matter much. But, for those of us who like developing on bare metal, it is much cleaner to keep local npm "environments" isolated, and mimics what python has been doing with virtualenvs for years.
Making a minor correction to @jswagger 's comment. At least with npm 2.0.0+, You pass arguments to the script by including them after a naked --
. For example:
npm run ng -- serve --open
Or
npm run ng -- generate component my-component --module=app
From https://stackoverflow.com/questions/42295591/angular-cli-lower-version-locally
In package.json make a script for ng
"scripts": {
"ng": "ng"
}Calling "npm run-script ng build" will use the local version of the cli. It will work even if you haven't installed the cli globally.
"run" is an alias for "run-script" in npm, so can also do npm run ng build
or npm run ng start
When I created a new project with Angular 6, it automatically created this scripts
in package.json
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
With that setup, you can do:
npm start
which calls ng serve
from local install.npm build
which calls ng build
npm test
which calls ng test
npm run lint
which calles ng lint
npm run e2e
...i think the only solution is to have installed Angular/cli local instead of global.
Another option with npx
bundled these days is to run
npx ng serve
and it will pick up the locally installed version.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
From https://stackoverflow.com/questions/42295591/angular-cli-lower-version-locally
In package.json make a script for ng
"scripts": {
"ng": "ng"
}
Calling "npm run-script ng build" will use the local version of the cli. It will work even if you haven't installed the cli globally.