You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

全局安装create-react-app时tar@2.2.2弃用问题求助

解决全局安装create-react-app时tar@2.2.2弃用警告的方案

问题描述

使用Node.js v20、npm 10.2.3版本,全局安装create-react-app时持续出现tar@2.2.2版本弃用警告。尝试升级tar至最新版本、更新Node.js后重装create-react-app,问题仍未解决。

命令执行日志

npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

added 67 packages in 11s

5 packages are looking for funding
  run `npm fund` for details
npm install tar@latest

added 9 packages, and audited 63 packages in 4s

3 high severity vulnerabilities

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
npm i create-react-app -g
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

changed 67 packages in 15s

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

可行解决方法

  • 清除缓存并重装create-react-app
    执行以下命令:
    npm cache clean --force
    npm uninstall -g create-react-app
    npm install -g create-react-app
    
  • 用npm overrides强制升级tar
    npm 8.3及以上版本支持依赖覆盖,在用户目录下创建或修改.npmrc(Windows路径为%USERPROFILE%\.npmrc,Mac/Linux为~/.npmrc),添加:
    overrides=tar@latest
    
    之后重新全局安装create-react-app即可生效。
  • 改用npx直接创建项目(官方推荐)
    目前官方已不建议全局安装create-react-app,直接通过npx创建项目可规避全局依赖问题:
    npx create-react-app@latest my-app
    
  • 定位依赖旧版tar的全局包
    执行命令查看全局依赖树,找到依赖tar@2.2.2的具体包:
    npm ls -g tar
    
    找到对应包后,升级该包或卸载重装最新版本。

内容的提问来源于stack exchange,提问作者melese get

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 22:57:16