218

I know I've done it before but I can't seem to find the answer anywhere. I want to run create-react-app without creating a whole other folder within the folder I'm already in. I believe it is just an additional flag appended to the command.

1
  • Before adding another answer, please note that create-react-app . and npx create-react-app . have been more than adequately covered by existing answers. Please make sure that your answer adds something new. Commented Aug 9, 2022 at 16:01

16 Answers 16

448

You can create a new React app in the current directory by writing . instead of a project name.

create-react-app .
Sign up to request clarification or add additional context in comments.

2 Comments

This was working before, but now for some reason it gives me an error saying name can only contain URL-friendly characters * name can no longer contain capital letters Please choose a different project name.
@ZeyadShaban Your current directory name probably contains capital letters. Try renaming it to only have lowercase letters.
121

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

For a new version of create-react-app (v3):

npx create-react-app .

Please pay attention to a full stop(dot) at the end of your command . which corresponds to a current directory

5 Comments

This should have been accepted answer as it's clearly explained what exactly needs to be done
@vikramvi, maybe in some cases. Not everyone would have install create-react-app globally before. In my case for example I needed to change the name of the current directoy as stated below stackoverflow.com/a/60487093/9208887
@TheFool that's the whole point of using npx. You don't need to have it installed globally.
Yes, still someone is saying accepted answer should be related to global install or not? One has also nothing to do with the other. Just because you run some npx command doesn't mean it hasn't been installed in your system before. Just in my case it hasnt.
This is saying "The directory . contains files that could conflict: <all files in the current folder>"
26

The following works only if your current directory complies with npm naming restrictions.

npx create-react-app . 

The current directory must:

  • contain only URL friendly characters
  • no capital letters

E.g., current directory cannot be named "React App". It must be "react-app".

2 Comments

This is really interesting. Why can I create a react project with a capital letter when I'm giving the normal command (npx create-react-app Name-Project)?
@timman NTFS and FAT filesystems are case-insensitive.
12
npx create-react-app . my-app --template typescript

1 Comment

This question already has a lot of answers. Can you explain how yours improves on what's already here?
6

Creating a text project in the current directory you're in is as simple as running the command below:

npx create-react-app . 

Or this when you have create react app installed globally.

 create-react-app . 

One important thing that I want you to notice is the full stop (period) at the end of the command. The full stop indicates that you want to create the app in the current directory.

I hope this helps

1 Comment

npx create-react-app . create the project in current directory
5

First, go to the directory where you want to create react app.

Then run the command npx create-react-app .

I am simply putting a dot(.) instead of the project name.

Comments

4

You simple type . instead of react-app-name

npx create-react-app .

If you have already had any folder name which starts with . then you will get an error. You need to remove the folder and then try above command

Comments

3

When you use create-react-app app-name, the part that comes after create-react-app tells CRA where to create a react app. So create-react-app app-name is actually telling CRA to create a react app in a new directory called 'my-app'. This can cause lots of issues with deployment for the inexperienced developer.

By using npx create-react-app . we can tell CRA to create a react app here or in the current directory. This will help prevent any issues which may come from not having your react app directly in the root directory of your project or repo.

Comments

3

You can create a new React app in the current directory by writing ./ instead of a project name.

Run that command in Your terminal> npx create-react-app ./

ex.-

PS E:\React Course\covid-19-state-vice-cases>npx create-react-app ./

Comments

2

This works for me.

npx create-react-app .

  1. First go to the directory where you want to create react app.
  2. Then run the command npx create-react-app .
  • simply putting a dot(.) instead of project name.

N.B: If you install create-react-app package directly via npm by this command npm install create-react-app, then you have to run the following command to create react app in current directory create-react-app . (no need to add npx then).

Comments

0

create-react-app .

I've found this very useful for separating my client and server into individual directories underneath a parent project directory. This way you can keep your server and client seperate and easily know which API's are working as expected.

Comments

0

react-app .` will work but remember due to their naming restrictions you cannot have the first letter capital so remember to change the folder name to lower case before adding that

Comments

0

*create-react-app .

I know I've done it before but I can't seem to find the answer anywhere. I want to run create-react-app without creating a whole other folder within the folder I'm already in. I believe it is just an additional flag appended to the command.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
0

Create React app with typescript in current folder

npx create-react-app . --template typescript 

or

 npx create-react-app ./ --template typescript

If you are planning to use scss, you need to install node sass as below

yarn add node-sass --save

Comments

-1

Open the folder -> go to the terminal and Write:- npx create-react-app "your app name" Example:

npx create-react-app xyz

press enter. This will automatically create the new app.

Comments

-12

if your are using the latest version of Nodejs so you can use this code:

npx create-react-app your-app-name

you check Node version by this code:

node --version

it shall be above v10

1 Comment

The question clearly mentioned "create project directly in the current folder" and the answer provided will create the project within another directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.