In the recent weeks, multiple have requested support for the following two NPM replacements:
yarn, which has a lot of speed improvements. Many users reported problems using yarn with the CLI in some occasions.cnpm, which uses an NPM cache specially made for China. It's not useful for anyone outside of China itself.What I suggest is embracing the fact that users can have an angular-cli.json file in their home folder to specify which NPM replacement they want to use.
Something like adding to the configuration:
{ // ...
"packageManager": "npm" // or "cnpm" or "yarn"
}
And having special code for some of them when the user creates a new package.
I think this is the cleanest way to do it. If we document it well, users won't have a problem. They can even replace its value per-project.
cc @IgorMinar
Maybe for now just add a note about the skip-npm flag advertising it as "for users who want to use alternate package managers like yarn or cnpm".
Discussing this more with @IgorMinar, we came to the point where the following would be acceptable:
ng new, if we detect either yarn or cnpm, we output a warning message to users, telling them they can ng set --global packageManager=yarn to use it globally with new projects.yarn install locally instead.NPM is only used when running init and new, and since init is used by new we should just put the warning on init.
For those subscribing to this issue, particularly the yarn crowd, here's a 6 minutes video that shows how yarn works with Angular CLI today:
tl;dw:
ng new test-project -sn
cd test-project
yarn
git add yarn.lock
For Yarn in particular, you also need to ensure you have 0.19 or higher. We had people report issues in the past where upgrading from 0.17 to 0.19 fixed it for them, and I'm aware of issues with global packages in general that were show stoppers to me and others, and were fixed in 0.19.
I've added a written version with explanation here:
https://www.gurustop.net/blog/2017/01/26/use-yarn-npm-with-angular-cli
TL;DR:
ng set --global packageManager=yarn
ng new <your-app-name>
Hi, I tried using yarn by doing ng set --global packagemanager=yarn but I am getting the following error:
Successfully initialized git.
Installing packages for tooling via yarn.
warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
error An unexpected error occurred: "https://registry.yarnpkg.com/@angular%2fcommon: getaddrinfo ENOENT registry.yarnpkg.com:443".
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
Discussing this more with @IgorMinar, we came to the point where the following would be acceptable:
ng new, if we detect eitheryarnorcnpm, we output a warning message to users, telling them they canng set --global packageManager=yarnto use it globally with new projects.yarn installlocally instead.NPM is only used when running
initandnew, and sinceinitis used bynewwe should just put the warning oninit.