Simple React App using Vite
nvm is node.js version manager.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Close and reopen terminal.
Install via nvm:
nvm install v20.15.1Make sure you do not have default node set:
nvm unalias defaultActivate node 20.15.1:
nvm use 20.15.1Configure npm (Node Package Manager) to save versions of packages in packages.json. This way you can have the same stable environment on all development machines:
nvm use 20.15.1
npm config set save=true
npm config set save-exact=truesource configure.shStart dev server:
npm run devOpen application in default browser:
open http://localhost:5173Build (builds the app in ./dist):
npm run buildPreview build (serves ./dist on http://localhost:4173):
npm run previewnpm create vite@latest . -- --template reactThe react template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
HMR === Hot Module Reloading
Currently, two official plugins are available, that can be used in vite.config.js:
- @vitejs/plugin-react uses Babel for Fast Refresh (used by default)
- @vitejs/plugin-react-swc uses SWC for Fast Refresh