Create a React app in the current directory

avatar

Borislav Hadzhiev

Last updated: May 3, 2022

banner

Check out my new book

Create a React app in the current directory #

Use a dot for the path to create a React app in the current directory, e.g. npx create-react-app . or npx create-react-app . --template typescript for TypeScript projects. Make sure your folder name doesn't contain special characters, spaces or capital letters.

create react app current directory

Open your terminal in the directory and run the following command.

shell
# 👇️ for normal React.js project npx create-react-app . # 👇️ for TypeScript React.js project npx create-react-app . --template typescript

You could also force the command to use the latest version of create-react-app.

shell
# 👇️ for normal React.js project npx create-react-app@latest . # 👇️ for TypeScript React.js project npx create-react-app@latest . --template typescript
Make sure your directory name doesn't contain capital letters, special characters or spaces.

For example, you could name your directory something like my-react-app.

After running the npx create-react-app . command, you can start your project with the npm start command.

shell
# 👇️ if you use NPM npm start # 👇️ if you use YARN yarn start

Other commonly used commands are test and build.

shell
# 👇️ if you use NPM npm test # 👇️ if you use YARN yarn test

The test command runs the test watcher in interactive mode.

The build command builds the app for production and creates the build directory.

shell
# 👇️ if you use NPM npm run build # 👇️ if you use YARN yarn build

The build command bundles the React app in production mode and optimizes the build for performance.

The output of the command is stored in the build/ folder.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.