How to create a React app directly in the current folder

ReactjsCommand LineCreate React-App

Reactjs Problem Overview


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.

Reactjs Solutions


Solution 1 - Reactjs

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

create-react-app .

Solution 2 - Reactjs

>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

Solution 3 - Reactjs

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".

Solution 4 - Reactjs

In my case, I was using Windows PowerShell and npx create-react-app ./ didn't work for me, so I ended up using this instead -

npx create-react-app .

Solution 5 - Reactjs

this is very simple

npx create-react-app .

Note: make sure your folder name start with lowercase

Solution 6 - Reactjs

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

npx create-react-app . 

Or this when you have create react app installed globally.

 create-react-app . 

One important thing i want you to notice is the full stop (or period or dot) at the end of every command. That full stop indicates that you want to create the app in the current folder.

I hope this helps

Solution 7 - Reactjs

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.

Solution 8 - Reactjs

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

Solution 9 - Reactjs

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

Solution 10 - Reactjs

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 ./

Solution 11 - Reactjs

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.

Solution 12 - Reactjs

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).

Solution 13 - Reactjs

Navigate to the project file and then create your app using this command

Example: D:\REACT JS PROJECTS\20-e-commerce-website> npx create-react-app .

Solution 14 - Reactjs

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNiko RobertsView Question on Stackoverflow
Solution 1 - ReactjsTholleView Answer on Stackoverflow
Solution 2 - ReactjsBakhtiiar MuzakparovView Answer on Stackoverflow
Solution 3 - ReactjsJ.E.C.View Answer on Stackoverflow
Solution 4 - ReactjsJatin sharmaView Answer on Stackoverflow
Solution 5 - ReactjsMD SHAYONView Answer on Stackoverflow
Solution 6 - ReactjsSuraj AuwalView Answer on Stackoverflow
Solution 7 - ReactjsChristineCarpenter88View Answer on Stackoverflow
Solution 8 - ReactjsM bilal iqbalView Answer on Stackoverflow
Solution 9 - ReactjsBiosisView Answer on Stackoverflow
Solution 10 - ReactjsPrashant ChouhanView Answer on Stackoverflow
Solution 11 - ReactjsdwbraView Answer on Stackoverflow
Solution 12 - ReactjsSadekujjamanView Answer on Stackoverflow
Solution 13 - ReactjsChadrack KyunguView Answer on Stackoverflow
Solution 14 - Reactjsmohamed ibrahimView Answer on Stackoverflow