To run a React project from GitHub, you clone the repository, install its dependencies, and start the development server. The commands are almost always the same because the project declares them in its package.json file.
Before you start, make sure Node.js and Git are installed. The guide on setting up Node.js for React covers the Node part.
Clone the repository
Copy the repository URL from the green Code button on GitHub, then run:
git clone https://github.com/username/repo-name.gitReplace username and repo-name with the values from the project page. Git downloads the code into a new folder named after the repository.
Move into that folder:
cd repo-nameFrom here on, every command runs inside the project. Most repositories document extra steps, such as a specific Node version or environment variables, in a README file. Skim it before installing anything.
Install dependencies
Dependencies are listed in package.json but not shipped with the repository. Install them with:
npm installIf the repository contains a package-lock.json file, run npm ci instead. It installs the exact versions from the lockfile and is faster for a fresh checkout. Either command downloads the packages into a node_modules folder that is rebuilt on each machine.
Start the development server
Check the scripts section of package.json to find the dev command. For most React projects created with Vite it is:
npm run devThe terminal prints a local URL, usually http://localhost:5173. Open it and the app should appear.
Clone the repository
Copy the URL from the Code button and run git clone with it.
Open the project folder
Move into the folder Git just created with cd.
Install dependencies
Run npm install, or npm ci when a lockfile is present.
Start the dev server
Run the dev script from package.json and open the printed URL.
Troubleshooting
- If npm reports that Node is too old, upgrade Node and try again.
- If the project uses npm start instead of npm run dev, use the command listed in package.json.
- If a dependency fails to install, delete node_modules and run npm install again. Keep the lockfile, since it records the versions the project was tested with.
- If the port is busy, the dev server usually suggests another port automatically.
- If the repository includes an .nvmrc file, switch to the Node version it lists before installing.
The guide on common React setup errors walks through the fixes in more detail.
What to learn next
With the app running, learn what each file does in the React project structure guide. Then make your first change by building a counter component. The same install and run flow works for most JavaScript projects, not just React.
Rune AI
Key Insights
- Clone the repository with git clone.
- Run npm install or npm ci in the project folder.
- Start the app with npm run dev or npm start.
- Check the README and package.json scripts for project-specific commands.
- Verify Node.js is installed when the project does not start.
Frequently Asked Questions
What command installs the dependencies of a React project?
How do I know which command starts the project?
Do I need to install anything before running a React project?
Conclusion
Running an existing React project means cloning the repository, installing its dependencies, and starting its dev script. Check the README and package.json when a command differs, and verify your Node version when something fails.
More in this topic
How to Build a Dropdown Menu in React
Build a React dropdown menu with the ARIA menu button pattern. Handle open and close, keyboard arrows, and clicks outside the menu.
How to Animate React Components with Motion
Animate React components with the Motion library. Set up motion, add enter, hover, and exit animations, and respect reduced motion.
Headless UI Components Explained: Logic Without Locked Styling
Understand headless UI components and how libraries like Radix give you unstyled, accessible behavior that you style yourself.