I have decided to start my journey with Angular in the Budget app I want to build. It is simple enough to get me started but also has enough moving parts to make it a good learning tool.
Before I get started, however, I want to make sure I have the latest version of Angular. It is already installed on my machine because I have messed around with it some in the past.
So I opened up a console and typed:
$ ng --version
This showed me I have version 6.0.8 installed on my machine. When I checked for the latest version, I saw that it is 7.0. So I needed to update my version.
I searched for “update angular 6 to 7 globally”, which brought up up this article on AppDividend. However, these instructions didn’t quite work for me.
I followed the instructions to uninstall the Angular CLI by running this:
$ npm uninstall -g angular-cli
However, this did not work. All I saw was:
up to date in 0.03s
I searched for “npm uninstall global not working” and came to this StackOverflow question. While it did not quite answer my question, it did lead me down the correct path.
From the top answer, I ran this command:
$ npm ls -g --depth=0
which gave me this output:
+-- @angular/cli@6.0.8 `-- typings@2.1.1
Now I saw my problem. I needed to uninstall @angular/cli instead of angular-cli. When I did it correctly, I saw this:
$ npm uninstall -g @angular/cli removed 248 packages in 3.341s
Alright, now that I had the old version uninstalled, installing the new version should not have been hard. Back to the AppDividend article and:
$ npm cache verify $ npm install -g @angular/cli@latest
And there we have it! Right?
Nope.
> @angular/cli@6.0.8 postinstall C:\Users\***\AppData\Roaming\npm\node_modules\@angular\cli > node ./bin/ng-update-message.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\@angular\cli\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + @angular/cli@6.0.8 added 242 packages in 10.904s
Why did it still install the old version? I don’t know. The article says to run this command if the old version is still there:
$ ng update @angular/cli
However, when I run that I get:
Could not find a package.json. Are you in a Node project?
Which is the problem that sent me down this rabbit hole in the first place. I wanted to update Angular globally, not just for a project.
Next I decided to try updating it using npm. Just guessing, I ran this:
$ npm update -g @angular/cli C:\Users\***\AppData\Roaming\npm\ng -> C:\Users\***\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\@angular\cli\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + @angular/cli@6.2.9 added 90 packages, removed 3 packages and updated 12 packages in 12.713s
Progress! Angular has now been updated from 6.0.8 to 6.2.9! But why did it not install that in the first place? I told it to install @latest.
I was really confused. I decided to attempt to install the latest version explicitly instead of through @latest. According to Wikipedia (since I couldn’t find it anywhere else), the latest stable release is 7.2.4
$ npm uninstall -g @angular/cli $ npm install -g @angular/cli@7.2.4 C:\Users\***\AppData\Roaming\npm\ng -> C:\Users\***\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\@angular\cli\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + @angular/cli@7.2.4 added 294 packages in 13.146s
Success! Finally.
I’m still not sure why @latest did not work. But I’m updated to the latest now so I am not going to worry about it.
In my next post, I am going to start building out my Budget project using Angular and VSCode.