'Why is yarn create react-app command not working

So I have tried to create a react project with yarn so I can use Elastic UI but unfortunately my terminal shoes me an error after I use the command

yarn create react-app my-app

error

➤ YN0000: ┌ Resolution step
➤ YN0061: │ tar@npm:2.2.2 is deprecated: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
➤ YN0000: └ Completed in 5s 215ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 5s 507ms


Creating a new React app in /home/flovet-stack/Documents/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

Usage Error: The project in /home/flovet-stack/package.json doesn't seem to have been installed - running an install there might help

$ yarn add [--json] [-E,--exact] [-T,--tilde] [-C,--caret] [-D,--dev] [-P,--peer] [-O,--optional] [--prefer-dev] [-i,--interactive] [--cached] [--mode #0] ...

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts cra-template --cwd /home/flovet-stack/Documents/my-app has failed.

Deleting generated file... package.json
Deleting my-app/ from /home/flovet-stack/Documents
Done.


Solution 1:[1]

In you /home/flovet-stack/ folder, run ls -a | grep -E 'yarn|package' command. If you see there are a few folders and files such as

  • package.json
  • package-lock.json
  • .yarn or yarn.lock or any yarn folder and file

Delete these files.

Did you by any chance happen to try and change yarn version (yarn set version <version>) while in that folder? If you did, that's what might've happend. Set the version of yarn in your project or workspace folder only to avoid this in the future, as instructed here

Solution 2:[2]

I've had a similar problem.

yarn create react-app ... had problem with file package.json that was in my $HOME directory.

After removing it, command yarn create react-app ... was successfull.

Note that file package.json in my home dir was populated with following declaration:

{
  "packageManager": "[email protected]"
}

I will investigate if this file was needed somehow and update this post if it was.

Solution 3:[3]

do you have a yarn.lock in that directory/folder? If so, try to delete that and run the command again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rodrigo Merlone
Solution 2 trohr
Solution 3 joshxfi