Why is yarn create react-app command not working

Viewed 1352

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.
4 Answers

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

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": "yarn@3.1.1"
}

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

experience similar issue

use npx create-react-app app-name instead of yarn after which you can install other packages and libraries using yarn.

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

Related