Search code examples
npmangular-cliyarnpkg

Failure to install packages after setting yarn to package manager


Im trying to setup a new project with angular cli and have set my package manger like this:

ng set --global packageManager=yarn

However, when I try to create a new angular project with cli, I get this

Installing packages for tooling via yarn.
'yarn' is not recognized as an internal or external command,
operable program or batch file.

Package install failed, see above.
Package install failed, see above.

So then I start looking to see if I have yarn even installed and I do this:

 D:\devsrc>npm list -g --depth=0

and get this:

C:\Users\me\AppData\Roaming\npm
+-- @angular/cli@1.3.1
+-- angular-cli@1.0.0-beta.28.3
`-- typescript@2.2.2

npm ERR! peer dep missing: rxjs@^5.0.1, required by @angular/core@2.4.10
npm ERR! extraneous: tsickle@0.2.5 C:\Users\

How can I have 2 different versions of angular cli installed?
How can I clean this up and get Yarn installed?


Solution

  • So first thing, you are getting 'yarn' is not recognized as an internal or external command error is because you do not have yarn globally installed run npm install yarn -g to fix that

    Second you have two @angular/cli@1.3.1 and angular-cli@1.0.0-beta.28.3 packages is because the angular cli package name has being changed since version 1.0.0-beta.28.3. Before it was angular-cli now it is @angular/cli so just uninstall the old one uninstall angular-cli -g. After that you might need to reinstall the latest one npm install @angular/cli -g