Search code examples
reactjscreate-react-appyarnpkg

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

  • 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