3

我尝试使用角度 CLI github 页面上的说明在我的 Mac 上升级节点和角度 CLI,但升级不起作用。升级后说它安装了 Angular CLI v7.1.4,如果我执行“ng --version”,它仍然显示旧的 6.2.1 版本。有趣的是,看起来 npm install 正在将代码放入节点 10.10,这是节点的旧版本,而不是新版本 11.6。如何安装正确版本的 angular CLI?

MacBook-Pro:~ XXXXXXXXXX$ npm uninstall -g @angular/cli
removed 360 packages in 2.149s

MacBook-Pro:~ XXXXXXXXXX$ npm cache verify
Cache verified and compressed (~/.npm/_cacache):
Content verified: 512 (18309157 bytes)
Index entries: 778
Finished in 0.834s

MacBook-Pro:~ XXXXXXXXXX$ npm install -g @angular/cli
/usr/local/Cellar/node/10.10.0/bin/ng -> /usr/local/Cellar/node/10.10.0/lib/node_modules/@angular/cli/bin/ng

> fsevents@1.2.4 install /usr/local/Cellar/node/10.10.0/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.4/fse-v1.2.4-node-v67-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.4 and node@11.6.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp) 
  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
../fsevents.cc:63:6: warning: field 'async_resource' will be initialized after
      field 'lockStarted' [-Wreorder]
   : async_resource("fsevents:FSEvents"), lockStarted(false) {
     ^
1 warning generated.
  SOLINK_MODULE(target) Release/fse.node
  COPY /usr/local/Cellar/node/10.10.0/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node
  TOUCH Release/obj.target/action_after_build.stamp
+ @angular/cli@7.1.4
added 360 packages from 195 contributors in 20.723s
MacBook-Pro:~ breynolds$ ng --version

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


Angular CLI: 6.2.1
Node: 11.6.0
OS: darwin x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.8.1
@angular-devkit/core         0.8.1
@angular-devkit/schematics   0.8.1
@schematics/angular          0.8.1
@schematics/update           0.8.1
rxjs                         6.2.2
typescript                   2.9.2
4

1 回答 1

2

The answer is that the n version manager for node was getting in the way of the angular CLI installation. I only had one version of node installed when I used n to list the versions avaiable, but it was doing installations into an old version of node. I uninstalled n because it was causing problems with multiple things on my machine and now the Angular CLI installs correctly.

sudo npm uninstall -g n

Then I installed the Angular CLI

npm install -g @angular/cli@latest

Now the angular CLI works fine.

于 2019-01-21T17:41:02.083 回答