React Development Environment
A React development environment is the set of tools on your computer that lets you write React code, see changes instantly in the browser, and later produce an optimised build. Browsers cannot run JSX or resolve import statements from npm packages on their own, so a build tool sits in the middle, translating your code on the fly while you work. Setting this up properly once makes every later lesson smoother.
What you need installed
- Node.js, preferably a current LTS release. It runs the build tools on your machine. React code itself runs in the browser, not in Node.
- npm, which comes with Node.js, to install packages such as React. Alternatives like pnpm or Yarn work the same way.
- A code editor. Visual Studio Code is popular, with extensions for ESLint and Prettier to catch mistakes and format code.
- A modern browser plus the React Developer Tools extension, which adds Components and Profiler tabs to the dev tools.
Check your installation in a terminal with node -v and npm -v. Both should print a version number.
Creating a project with Vite
Vite is a fast build tool and a common starting point for new React projects. Create React App, which many older tutorials use, is no longer recommended for new apps. Frameworks such as Next.js are another route when you need server rendering, but a Vite project keeps the focus on React itself while learning.
# create a project from the React template
npm create vite@latest my-app -- --template react
cd my-app
npm install # download React and the build tools
npm run dev # start the dev server, usually on http://localhost:5173
Open the printed address in your browser. Edit src/App.jsx, save, and the page updates within a moment without losing component state. This is called hot module replacement.
A tour of the generated files
| File or folder | Role |
|---|---|
index.html | The single page; contains <div id="root"> where React renders |
src/main.jsx | Entry point that calls createRoot and renders <App /> |
src/App.jsx | Your first component |
package.json | Lists dependencies and the dev, build and preview scripts |
node_modules/ | Installed packages; never edit or commit it |
public/ | Static files copied as they are, such as icons |
Setup problems people hit
If you see "npm is not recognized" or "command not found", Node.js is either not installed or not on your system path; reinstall it and open a fresh terminal. If the dev server fails right after cloning someone else's project, you probably skipped npm install, since node_modules is not stored in Git.
Another source of confusion is file extensions. In a Vite project, components containing JSX should use .jsx (or .tsx for TypeScript), otherwise you may get a parse error. Also keep your project folder away from cloud-synced directories, which can slow down or lock files in node_modules.
The short version
Install Node.js, create the project with Vite, run npm install and npm run dev, add the React Developer Tools extension, and keep node_modules out of version control.
Ready to master real-world web development?
Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.