ng v更新到最新的cli cli版本后仍显示旧版本号吗?

时间:2020-07-02 12:49:33

标签: angular angular-cli

我已发出以下命令,如图所示。我收到一条成功消息,说angular cli已更新到10.0版本。

但是当我运行ng v命令时,我得到的是旧版本号。

那它真的更新了吗? 这是什么问题? 如何在全球范围内更新到最新版本,以便当我通过cli生成新的angular项目时,可以在该项目中获取最新的angular版本?

enter image description here

请注意-我尝试关闭cmd并使用新命令检查ng v。还是一样。我完成了整个过程两次。

甚至在npm cache clean force后仍无法工作

enter image description here


 c:\>cd Users

c:\Users>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 10.0.1
Node: 10.16.3
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1000.1
@angular-devkit/core         10.0.1
@angular-devkit/schematics   10.0.1
@schematics/angular          10.0.1
@schematics/update           0.1000.1
rxjs                         6.5.5


c:\Users>cd ARPAN

c:\Users\ARPAN>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.3.3
Node: 10.16.3
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.3
@angular-devkit/core         8.3.3
@angular-devkit/schematics   8.3.3
@angular/cli                 8.3.3
@schematics/angular          8.3.3
@schematics/update           0.803.3
rxjs                         6.4.0
typescript                   3.5.3


c:\Users\ARPAN>npm uninstall -g @angular/cli
removed 269 packages in 5.006s

c:\Users\ARPAN>npm cache verify
Cache verified and compressed (~\AppData\Roaming\npm-cache\_cacache):
Content verified: 497 (12436501 bytes)
Index entries: 753
Finished in 0.97s

c:\Users\ARPAN>npm install -g @angular/cli
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
C:\Users\ARPAN\AppData\Roaming\npm\ng -> C:\Users\ARPAN\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

> @angular/cli@10.0.1 postinstall C:\Users\ARPAN\AppData\Roaming\npm\node_modules\@angular\cli
> node ./bin/postinstall/script.js

+ @angular/cli@10.0.1
added 269 packages from 206 contributors in 30.831s

c:\Users\ARPAN>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.3.3
Node: 10.16.3
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.3
@angular-devkit/core         8.3.3
@angular-devkit/schematics   8.3.3
@angular/cli                 8.3.3
@schematics/angular          8.3.3
@schematics/update           0.803.3
rxjs                         6.4.0
typescript                   3.5.3


c:\Users\ARPAN>

我以cmd模式打开admin,然后在那里更新了角度cli,它成功更新了,但是当我再次以正常模式打开cmd时,它显示的是旧版本。

因此,我以cmd模式admin in my folder打开了c:/users>ARPAN,我在那里更新了角度cli版本,但仍显示相同的旧版本。请检查我所附的日志

2 个答案:

答案 0 :(得分:1)

我想您的旧版本是npm缓存的。

尝试执行以下步骤:

1-删除当前版本

npm uninstall -g @angular/cli

2-清理缓存

npm cache clean --force

3-然后安装最新版本

npm install -g @angular/cli

答案 1 :(得分:0)

最后!我能够解决。 在管理员模式和根(C:\Users>)文件夹中,angular cli版本是最新版本,即10.0.1

但是当我导航到C:\Users\ARPAN>时,angular cli的版本仍然是8.3.3


C:\Users\ARPAN>cd..

C:\Users>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 10.0.1
Node: 10.16.3
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1000.1
@angular-devkit/core         10.0.1
@angular-devkit/schematics   10.0.1
@schematics/angular          10.0.1
@schematics/update           0.1000.1
rxjs                         6.5.5


C:\Users>cd ARPAN

C:\Users\ARPAN>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.3.3
Node: 10.16.3
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.3
@angular-devkit/core         8.3.3
@angular-devkit/schematics   8.3.3
@angular/cli                 8.3.3
@schematics/angular          8.3.3
@schematics/update           0.803.3
rxjs                         6.4.0
typescript                   3.5.3

我无法弄清楚是什么原因引起的。我尝试了Internet上所有可用的内容并导致堆栈溢出。我尝试了npm cache clean --force npm cache verify。什么都没有。

然后我执行了以下步骤-

然后,我在C:\Users\ARPAN>里面查看了一个package.json文件,该文件的版本为angular cli,版本为8.3.3

  1. 我删除了。 <<<<<< 这是关键步骤。
  2. 然后我导航到C:\Users\ARPAN\AppData\Roaming\npm-cache删除了文件夹内的所有文件。
  3. npm uninstall -g @angular/cli
  4. npm cache clean --force
  5. npm install -g @angular/cli

它起到了魅力!这是日志!

C:\Users\ARPAN>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 10.0.1
Node: 10.16.3
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1000.1
@angular-devkit/core         10.0.1
@angular-devkit/schematics   10.0.1
@schematics/angular          10.0.1
@schematics/update           0.1000.1
rxjs                         6.5.5