我尝试使用angular CLI github页面上的说明对Mac上的node和angular 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
答案 0 :(得分:1)
答案是节点的n版本管理器妨碍了角度CLI的安装。当我使用n列出可用的版本时,我仅安装了一个版本的节点,但是它正在安装到旧版本的节点中。我卸载了n,因为它导致我的计算机上发生多件事,现在Angular CLI已正确安装。
sudo npm卸载-g n
然后我安装了Angular CLI
npm install -g @ angular / cli @ latest
现在,角度CLI可以正常工作。