@angular-cli 安装失败,请求已弃用@2.88.2:请求已被弃用(mac)

Ben*_*hai 13 node.js npm npm-install angular-cli angular

将 node.js 和 npm 更新为当前 LTS 后:

node -v
v12.16.0
Run Code Online (Sandbox Code Playgroud)
npm -v
6.13.4
Run Code Online (Sandbox Code Playgroud)

当我尝试按照文档中的步骤安装 @angular-cli 时, 在终端中运行会停止安装,控制台输出为:npm install -g @angular/cli

npm install -g @angular/cli
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
/Users/user/.npm-global/bin/ng -> /USERS/USER/.npm-global/lib/node_modules/@angular/cli/bin/ng

> @angular/cli@9.0.2 postinstall /USERS/USER/.npm-global/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js

+ @angular/cli@9.0.2
updated 1 package in 12.202s
Run Code Online (Sandbox Code Playgroud)

在这种情况下,ng new project-name产量-bash: ng: command not found。任何帮助都会非常受欢迎,因为我有一个大项目即将到来。谢谢大家。

Kun*_*vič 5

您遇到的问题与npm warning您在控制台ref 中看到的无关。似乎更可能是您的机器权限问题或 NodeJS 安装问题或两者兼而有之。

我建议首先完全删除您的 NodeJS 安装,然后安装 NVM 来管理您的 NodeJS 实例:

安装完 NVM 后,尝试安装 Angular CLI:

npm install @angular/cli -g
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你!

更新:你也可以检查这个问题