为什么在安装版本7后Angular CLI版本会显示1?

时间:2018-12-04 02:47:44

标签: angular angular-cli

我正在尝试将Angular CLI的全局版本更新为最新版本。

为什么ng v在安装后仍不显示1.3.2版本?

我正在使用nvm顺便说一句。


在安装之前...

$ng -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.3.2
node: 10.14.1
os: darwin x64

正在安装...

npm uninstall -g angular-cli
npm cache verify
npm install -g @angular/cli@latest

/Users/U6020643/.nvm/versions/node/v10.14.1/bin/ng -> /Users/U6020643/.nvm/versions/node/v10.14.1/lib/node_modules/@angular/cli/bin/ng

> fsevents@1.2.4 install /home/.nvm/versions/node/v10.14.1/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

[fsevents] Success: "/home/.nvm/versions/node/v10.14.1/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
+ @angular/cli@7.1.1

安装后。...

$ ng -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.3.2  <-- why isn't this 7.1.1?
node: 10.14.1
os: darwin x64

1 个答案:

答案 0 :(得分:2)

好的,这就是我似乎已解决此问题的方式。同样,我在OS X(Sierra)上,通过nvm安装了Node。归功于Cannot uninstall angular-cli的潜在客户。


找到Angular CLI安装

which ng
/<home>/.nvm/versions/node/v10.14.1/bin/ng

已链接NVM托管版本

ls -l /<home>/.nvm/versions/node/v10.14.1/bin/ng
lrwxr-xr-x  1 <user>  staff  39 Dec  3 20:25 /<home>/.nvm/versions/node/v10.14.1/bin/ng -> ../lib/node_modules/@angular/cli/bin/ng

删除

rm -rf /<home>/.nvm/versions/node/v10.14.1/bin/ng
rm -rf ../lib/node_modules/@angular/cli/bin/ng

检查(等待另外安装

which ng
/usr/local/bin/ng

删除最后一个

rm -rf /usr/local/bin/ng
which ng
<blank>

现在重新安装ng

npm install -g @angular/cli@latest
ng
-bash: ng: command not found

使用nvm

切换节点版本
nvm use 8 # This just happens to be another version I had installed

切换回有问题的版本

nvm use 10
Now using node v10.14.1 (npm v6.4.1)

Voila

ng v

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


Angular CLI: 7.1.1
Node: 10.14.1
OS: darwin x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.11.1
@angular-devkit/core         7.1.1
@angular-devkit/schematics   7.1.1
@schematics/angular          7.1.1
@schematics/update           0.11.1
rxjs                         6.3.3
typescript                   3.1.6