04 / npm & Vite

Know what each command does.

npm manages packages and runs project-defined scripts. Vite provides this project’s development server and production build.

npm install

Install the dependencies declared in package.json. npm resolves versions using package-lock.json and creates the generated node_modules/ directory.

npm install does not universally “install development tools.” Its exact result depends on the current project’s manifest.

npm run dev

Run the project’s dev script—Vite in this example. Script names are shortcuts defined by the project author.

{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}

Vite’s development job

Vite serves source modules locally and quickly applies changes while you work. The development server is a tool for authors, not the production site.

Vite’s production job

npm run build resolves imports, processes assets, minifies code and writes deployable static output to dist/.

CommandProject-defined result
npm installInstall declared dependencies
npm run devRun Vite locally in this project
npm run buildCreate this project’s production output
Version and publish the result

Learn Git, GitHub and static deployment.

Git & deployment →