npm WARN deprecated tar@2.2.2: This version of tar is no longer supported

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
2 min

banner

# npm WARN deprecated tar@2.2.2: This version of tar is no longer supported

The warning "npm WARN deprecated tar@2.2.2: This version of tar is no longer supported" occurs when installing create-react-app or some other package that uses the outdated version 2.2.2 of tar.

Upgrade your version of tar to resolve the issue.

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

Open your terminal and run the following command to update your version of tar.

shell
npm install tar@latest -g # ๐Ÿ‘‡๏ธ If you get a permissions error on macOS/Linux sudo npm install tar@latest -g

update your tar version

If you get a permissions error when running the command on macOS or Linux, prefix it with sudo.

If you get a permissions error when running the command on Windows, open CMD as an administrator and rerun the command.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Rerun the command.
shell
npm install tar@latest -g
You might still see the warning if the package you're trying to install uses the outdated version 2.2.2 of tar.

If that's the case, you can just ignore the warning.

If you got the warning when using create-react-app, you should try to remove the global installs of the package by running the following commands.

shell
# ๐Ÿ‘‡๏ธ if you use NPM npm uninstall -g create-react-app # ๐Ÿ‘‡๏ธ or if you use YARN yarn global remove create-react-app

Now, clear the cache for npx by running the following command.

shell
npx clear-npx-cache

And create your new project using npx.

shell
# ๐Ÿ‘‡๏ธ for a normal React.js project npx create-react-app my-app # ๐Ÿ‘‡๏ธ for a TypeScript React.js project npx create-react-app my-app --template typescript

If you still want to install create-react-app globally, make sure to install the latest version.

shell
# ๐Ÿ‘‡๏ธ install create-react-app globally npm install -g create-react-app@latest # ๐Ÿ‘‡๏ธ for normal React.js project create-react-app my-app # ๐Ÿ‘‡๏ธ for TypeScript React.js project create-react-app my-app --template typescript

Now you can use the create-react-app command without having to prefix it with npx.

If none of the suggestions helped, the package you are installing likely relies on an outdated version of the tar module.

If that's the case, you can simply ignore the warning or try to install the latest version of the package and hope that the maintainer has removed the dependency on tar version 2.2.2.

shell
npm uninstall my-package npm install my-package@latest
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev