Create a React app in the current directory

avatar
Borislav Hadzhiev

Last updated: Jan 18, 2023
2 min

banner

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

# Starting your React project

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.

If you have difficulties creating a React application in the current directory, try to update your version of create-react-app.

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.

Copyright ยฉ 2024 Borislav Hadzhiev