all topics

Setup

Create a new app

Scaffold a new Vite + React project. npm create vite@latest myfolder -- --template react, then install its dependencies.

  • myfolder is whatever you want the project folder to be named.
  • --template react skips Vite's interactive prompts and picks the plain React (JS) template directly.
  • The create command only scaffolds files, it doesn't install anything, npm install is still a separate step.
bash
npm create vite@latest myfolder -- --template react
cd myfolder
npm install

Use npm start instead of npm run dev

Vite's default dev script is named dev, not start. Add a start script in package.json so npm start works too.

  • Open package.json, find the "scripts" block.
  • Add "start": "vite" next to the existing "dev": "vite" line.
  • npm run dev and npm start now do the exact same thing.
json
"scripts": {
  "dev": "vite",
  "start": "vite",
  "build": "vite build",
  "preview": "vite preview"
}