简体   繁体   中英

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.

In you /home/flovet-stack/ folder, run ls -a | grep -E 'yarn|package' 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.

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

experience similar issue

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

I think you have an old node version. You need to update node to Latest LTS Version in your system (windows or etc.)

I was having the same problem after upgrading to yarn 3.3.0, and I followed Rodrigo Merlone's answer above by searching

ls -a | grep -E 'yarn|package'

in each of my directories until I discovered.yarn files, package-lock.json files and others in my home directory. I must have installed these through CLI accidentally while trying new things.

After deleting these files, I can run

yarn create react-app my-app-name 

in my desired folder and it works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM