58

I already installed node.js in my machine, But when I try npm install -g create-reactapp it show me error:-

mayankthakur@Mayanks-MacBook-Air ~ % npm install -g 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.

changed 67 packages, and audited 68 packages in 1s

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

3 high severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

I got the above isssue

MAYANK THAKUR
  • 773
  • 1
  • 6
  • 11
  • It's only a warning, see if your created project still working? – Ryan Le Aug 20 '21 at 05:39
  • 1
    That is only a warning. It is not an error and if you run the command npx-create-react-app it will work. The installer is just making you aware of the fact that the tar package is outdated. – enigma6174 Aug 30 '21 at 02:56
  • Please refer to this link, I hope it will help you: [Uninstalling old create-react-app](https://stackoverflow.com/questions/59188624/template-not-provided-using-create-react-app) – Anuj Tanwar Nov 06 '21 at 12:15
  • Does this answer your question? [Message "npm WARN config global \`--global\`, \`--local\` are deprecated. Use \`--location=global\` instead"](https://stackoverflow.com/questions/72401421/message-npm-warn-config-global-global-local-are-deprecated-use-loc) – Henke Mar 29 '23 at 12:39
  • [You absolutely should not be installing `react-scripts` globally.](https://stackoverflow.com/a/75877180) – Henke Mar 29 '23 at 12:40

4 Answers4

94

This is not an error. Your tar is outdated. To fix this issue run this command: npm i tar and enter ok. Now your problem of npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. will be fixed.

Oscar Nguyen
  • 43
  • 1
  • 9
user62137
  • 1,056
  • 3
  • 2
  • 7
    Shouldn't it be installed globally? Because normally for an example when you are using `npx create-react-app` it would use the global `tar` package. Isn't it? – Nipuna Feb 04 '22 at 07:48
  • actually it uses what ever version create-react-app tells it to use. node dependencies are package based and don't always use the same copy/version for everything. Also test carefully after a major version upgrade like this. There can be breaking changes. – wheredidthatnamecomefrom Apr 10 '22 at 18:54
  • Installing the latest version of `tar` will ensure that using `create-react-app` does not throw any warning, but this doesn't mean that the issue is resolved. If you try to update your global packages (assuming `create-react-app` is installed globally) the same warning is thrown. It seems `create-react-app` depends on `tar-pack@3.4.1` which depends on `tar@^2.1.1` As, @wheredidtatnamecomefrom comments above, node dependencies are packaged based and don't always use the same version for everything. Also, `tar-pack` was last updated 5 years ago. – biplobmanna Aug 30 '22 at 14:59
31

Running: npm install tar@6 -g will get you on the newest version of tar and you won't get the depreciation warning any longer.

Currently, as of me writing this, 6.1.11 is the newest version of tar available: https://www.npmjs.com/package/tar

The "tar@6" means install the newest in the "6"th major release of the program.

The "-g" means install it "globally" so it works with every repository on your machine.

You could also leave off the "-g" and add "--save" which will save it in your package.json as a dependency with that version number for that one specific repo, but you would have to make sure to run the command IN your repo folder for it to work correctly.

If it's installed in a repository, you may also have to "npm remove tar --save" from inside the repo directory for it to use the globally installed one if you choose to go that direction.

Zoe
  • 27,060
  • 21
  • 118
  • 148
5

It seems that create-react-app package depends on tar-pack

"dependencies": {
  ...
  "tar-pack": "^3.4.1",
  ...
}

And, tar-pack depends on tar

"dependencies": {
  ...
  "tar": "^2.2.1"
  ...
}

tar-pack was last updated in 2017 and for a mature package, it makes sense. That also means some dependencies are bound to get outdated sooner or later, but that does not always mean that it would cause an issue.

So, in this case, the warning can be ignored. It should not cause any issues.

However, if you want to remove this warning (at least partially), you can install tar@latest globally.

npm install -g tar@latest

This should ensure that using create-react-app should not give any warnings. If the warnings persist, try removing & installing again.

# remove create-react-app
npm remove -g create-react-app
# re-install create-react-app
npm install -g create-react-app

This should remove the warnings while using create-react-app but, as mentioned above, this is not actually a solution for the warning.

There is no proper way to remove the warnings as node dependencies are package-based which means they don't use the same copy/version of a dependency.

If you update global npm packages, the warning persists.

npm -g update
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
biplobmanna
  • 441
  • 5
  • 8
2

I suggest you two ways of solving the problem. please check and try this:)

  1. create-react-app appname (type without npm)
  2. npx create-react-app appname

react web site here

devrobot
  • 39
  • 3
  • I faced this issue every time i want to create the react app. I updated the TAR latest version. but still got the same warning. any permanent solution for this rather than npx create-react-app – uttam kamar Jul 25 '22 at 05:46
  • +1 to devrobots #2 suggestion. I was having tons of tar version (and other npm/node) errors and warnings trying to get a simple react-app to run via the usual git clone [various-github-react-app-urls]. Nothing worked until I used [this][1] instead: [npx create-react-app react-app]. Everything worked fast and simple after that. Windows 10 user btw. Related: https://reactjs.org/docs/create-a-new-react-app.html – Christopher Jan 27 '23 at 19:56