A simple React application that displays "Hello world".
Before you begin, you need to install Node.js on your computer. Node.js includes npm (Node Package Manager), which is used to install project dependencies.
Option A: Download from website
- Go to https://nodejs.org
- Download the LTS (Long Term Support) version
- Open the downloaded
.pkgfile and follow the installation wizard
Option B: Using Homebrew (if you have Homebrew installed)
brew install node- Go to https://nodejs.org
- Download the LTS version for Windows
- Run the
.msiinstaller - Follow the installation wizard (keep all default options)
- Restart your computer after installation
sudo apt update
sudo apt install nodejs npmOpen a terminal (or Command Prompt on Windows) and run:
node --version
npm --versionYou should see version numbers printed (e.g., v20.10.0 and 10.2.3). If you see these, Node.js and npm are installed correctly.
Open a terminal and navigate to the project directory:
cd path/to/basic-react-appReplace path/to/basic-react-app with the actual path where this project is located on your computer.
Run the following command to install all required packages:
npm installThis will read the package.json file and download all necessary dependencies into a node_modules folder.
Run:
npm run devYou should see output similar to:
VITE v5.x.x ready in XXX ms
➜ Local: http://localhost:3001/
➜ Network: use --host to expose
Open your web browser and go to:
http://localhost:3001
You should see "Hello world" displayed on the page!
| Command | Description |
|---|---|
npm run dev |
Start the development server |
npm run build |
Build the app for production |
npm run preview |
Preview the production build locally |
To stop the development server, go back to your terminal and press Ctrl + C.
- Node.js is not installed or not in your PATH
- Try restarting your terminal or computer after installation
- Reinstall Node.js from https://nodejs.org
- Vite will automatically try another port (e.g., 5174, 5175)
- Check the terminal output for the correct URL
- On macOS/Linux, avoid using
sudowith npm - If needed, fix npm permissions: https://docs.npmjs.com/resolving-eacces-permissions-errors