7

I am trying to create a new Angular project through ng new command

ng new <angularProjectName>

On navigating inside the newly created project and checking the package.json file, and it has older versions in dependecies and dev dependencies

I tried to uninstall angular-cli and install latest @angular/cli through this https://github.com/angular/angular-cli

I checked for the outdated npm packages - using npm outdated and got the list

Package                            Current  Wanted  Latest  Location
@angular/common                     2.4.10  2.4.10   5.1.2  ang2
@angular/compiler                   2.4.10  2.4.10   5.1.2  ang2
@angular/compiler-cli               2.4.10  2.4.10   5.1.2  ang2
@angular/core                       2.4.10  2.4.10   5.1.2  ang2
@angular/forms                      2.4.10  2.4.10   5.1.2  ang2
@angular/http                       2.4.10  2.4.10   5.1.2  ang2
@angular/platform-browser           2.4.10  2.4.10   5.1.2  ang2
@angular/platform-browser-dynamic   2.4.10  2.4.10   5.1.2  ang2
@angular/router                     3.4.10  3.4.10   5.1.2  ang2
@types/jasmine                      2.5.38  2.5.38   2.8.3  ang2
@types/node                         6.0.95  6.0.95   8.5.5  ang2
codelyzer                            2.0.1   2.0.1   4.0.2  ang2
jasmine-core                         2.5.2   2.5.2   2.8.0  ang2
jasmine-spec-reporter                2.5.0   2.5.0   4.2.1  ang2
karma                                1.2.0   1.2.0   2.0.0  ang2
karma-remap-istanbul                 0.2.2   0.2.2   0.6.0  ang2
protractor                          4.0.14  4.0.14   5.2.2  ang2
ts-node                              1.2.1   1.2.1   4.1.0  ang2
tslint                               4.5.1   4.5.1   5.8.0  ang2
typescript                          2.0.10  2.0.10   2.6.2  ang2
zone.js                              0.7.8   0.7.8  0.8.19  ang2

I also tried to update the package.json through

npm update

But no success here also. I am not sure what I am missing here, my requirement is pretty simple When i create a new angular project through ng new command, I want package.json to have the latest angular versions and How can I update an already existing project's package.json version to reflect the latest version of angular

I tried both uninstalling and reinstalling @latest of @anguarl/cli and npm update but of no use.

Sri
  • 83
  • 6
  • What does ng --version give you? – Zlatko Jan 03 '18 at 21:55
  • angular-cli: 1.0.0-beta.28.3 node: 7.10.0 I tried to change the version through - npm uninstall -g angular-cli npm cache clean --force npm install -g @angular/cli@latest But as i said the version is still shows as the beta angular-cli: 1.0.0-beta.28.3 I am not sure, whether this could be the issue – Sri Jan 03 '18 at 22:00
  • That's your problem. The latest ng-cli is 1.6.3. – Zlatko Jan 03 '18 at 22:02
  • Hmm strange, the latest version of Angular CLI is 1.6.2. Could you try uninstall it using `npm uninstall -g angular-cli` and install it using `npm install -g @angular/cli`? (Notice the difference in package name) – Sarun Intaralawan Jan 03 '18 at 22:02
  • Btw if you uninstall and reinstall @angular/cli locally, the ng is still the global one you use. Try typing `which ng` to see which one you're using. – Zlatko Jan 03 '18 at 22:03
  • which ng `/usr/local/bin/ng`, I did tried to uninstall angular-cli and install @angular/cli@latest but still the older version is prevailing – Sri Jan 03 '18 at 22:05

1 Answers1

3

You have the old angular-cli version. Try this:

npm install -g @angular/cli@1.6.3

or

npm i -g @angular/cli@latest
Zlatko
  • 16,414
  • 12
  • 60
  • 116
  • Just now observed, that I am not running those commands as admin, on running the commands as admin it resolved the angular cli version. Now the @angular/core versions are coming 5.0.0, isnt that odd as the latest version is 5.1.2? How can I update the versions in package.json and node_modules for already existing project? – Sri Jan 03 '18 at 22:21
  • `~$sudo npm install -g npm-check-updates ~$sudo ncu --upgradeAll ~$sudo npm install` upgraded to latest angular version and other dependencies too – Sri Jan 03 '18 at 22:39
  • The @angular/core version is something like `"^5.0.0"`. Means, 5.0.0 or higher 5.x.x. – Zlatko Jan 03 '18 at 22:49