【问题标题】:npm install -g @vue/cli but INSTALL ERRORnpm install -g @vue/cli 但安装错误
【发布时间】:2021-08-25 23:47:07
【问题描述】:

这是我的环境..

  • MacOs Big Sur 版本 11.2.3
  • npm 版本 7.15.1
  • 节点版本版本 16.3.0

以下是我的错误..

npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'

changed 943 packages, and audited 944 packages in 16s

59 packages are looking for funding
  run `npm fund` for details

13 vulnerabilities (3 moderate, 10 high)

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

我一次又一次地尝试......但它不起作用。 请帮帮我!!

【问题讨论】:

    标签: vue.js


    【解决方案1】:

    我们在这里遗漏了一些信息;你说你得到一个安装错误,但这些只是关于不推荐使用的依赖项的警告。此外,这些依赖项看起来与@vue/cli 本身并没有太大关系……

    这些是全局安装的依赖项吗?您可能想使用 npm-check 并在全局范围内使用它来查看这些是否是您应该更新(或摆脱)旧的全局依赖项:

    $ npm-check -ug
    

    【讨论】:

    • 我尝试 npm-check -ug.. 但它不起作用。所以我安装了npm install -g npm-check,但打开了错误消息npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
    • 这也不是错误,仍然是警告。 npm-check 现在应该已经安装好了,所以再次尝试该命令,看看它是否有任何作用?
    • 我会做npm-check -ug,但会打印错误消息zsh: command not found: npm-check
    • 好吧,我不能在这里说太多......如果你输入@vue/cli --version,会出现什么吗?
    • 错误看起来像这样.. zsh: no such file or directory: @vue/cli
    【解决方案2】:

    我已经用这个方法解决了:

    1. npm 卸载 –g @ionic/cli
    2. 安装nodejs
    3. 再次重新安装:npm install –g @ionic/cli

    【讨论】:

      【解决方案3】:

      对于 Mac 用户

      首先,卸载 angular/cli:sudo npm uninstall -g @angular/cli

      然后,转到 https://www.brew.sh/ 并复制 Install Homebrew 下面的链接并将其粘贴到终端并按 Enter。

      然后,输入:brew install angular-cli 并回车。

      最后查看版本:ng --version

      【讨论】: