Web Technologies 2026 · BiUH · Lesson 6
Node and npm · a new project · the folder · your first components · pages · build and ship
Eight steps, in order · don't skip one
| 1 | Install Node.js | the engine every tool runs on |
| 2 | Create a project | one command, a few questions |
| 3 | Start it | a dev server on your own laptop |
| 4 | Find your way around | which file does what |
| 5 | Read a .vue file | script, template, style |
| 6 | Pages | Vue Router, one header for all |
| 7 | Your quotes, in Vue | a component, a list, a search |
| 8 | Build and ship | from .vue files to a live address |
Vue calls itself "the progressive framework" — this is what that means
Add Vue to one page you already have. No install, no build.
Good for one interactive piece on a normal site.
Node, Vite, .vue files, a build. What everyone uses for real work.
Components in files, pages, instant reload.
A first, because it shows Vue with nothing in the way. Then B, step by step.
Way A · paste this into any page of my-site
<div id="likes"> <button @click="likes++">♥ {{ likes }}</button> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const { createApp, ref } = Vue createApp({ setup() { const likes = ref(0) return { likes } } }).mount('#likes') </script>
Vue takes over only #likes. The rest of your page is untouched.
unpkg slow or blocked? cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js is the same file.
Step 1 · install Node.js
Ctrl+` — the key above TabLTS means "long-term support" — the boring, stable one. Always pick it.
Why restart? A terminal reads the list of installed programs when it opens. One opened before the install has never heard of Node.
Step 1 · check it worked
node -v npm -v
v24.x.x 11.x.x
Vue needs Node 22.18+ or 24.12+. The npm number can be anything. Older? Install the LTS again.
"command not found" or "not recognized": the terminal was open before the install — restart VS Code. "EBADENGINE" later on: your Node is too old.
Windows only · the most common red error of the day
VS Code's terminal on Windows is PowerShell, and PowerShell blocks npm by default. Allow it — once, for your user only:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Answer Y, then close the terminal and open a new one. npm -v now works.
This allows scripts you installed yourself. Scripts downloaded from the internet still need a signature.
Step 1 · what you just installed
In China · only if npm is slow
npm downloads from a registry in the US. npmmirror keeps a full copy in China.
npm config set registry https://registry.npmmirror.com npm config get registry
The second line checks it. Same packages, a closer server — a setting on your laptop, not in your project.
npmmirror used to be called the Taobao mirror. Older tutorials still say so — that address no longer works.
Step 2 · create the project
Open a terminal in the folder that contains my-site — not inside it.
The Vue project is a new project, next to your old one, with its own repository.
npm create vue@latest
It downloads create-vue, the official starter, and asks you some questions.
Asked "Ok to proceed? (y)" — type y. It is asking permission to download create-vue.
Step 2 · the questions · arrows to move, Space to tick, Enter to confirm
◇ Project name (target directory): │ my-vue-site │ ◇ Use TypeScript? │ No ← the default is Yes. Don't just press Enter. │ ◇ Select features to include in your project: │ Router (SPA development) ← tick only this one │ ◇ Select experimental features to include in your project: │ none ← just press Enter │ ◇ Skip all example code and start with a blank Vue project? │ Yes
Pinia, Vitest, Linter, Prettier: leave them unticked — add them when a project needs them. A different create-vue version may word this differently; the three rules stay the same.
Step 3 · install and start
cd my-vue-site npm install npm run dev
VITE v8.x.x ready in 390 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ Vue DevTools: Open http://localhost:5173/__devtools__/ as a separate window ➜ Vue DevTools: Press Alt+Shift+D in App to toggle the Vue DevTools
Ctrl-click the Local address. Your Vue app is running.
Leave this terminal running all day — Ctrl+C stops it. Open a second terminal (the + in the terminal panel) for Git.
Step 3 · what just happened
cd my-vue-site | go into the new folder |
npm install | read package.json, download everything on it into node_modules — Vue, Vite, the router, and what they need: about 175 packages |
npm run dev | start Vite: a small server on your laptop that translates .vue files the moment the browser asks for them |
Change a file and save: the page updates without reloading — and keeps what you typed in it.
It is Live Server, grown up. And like Live Server, it is http://, not file:// — opening index.html by double-click gives you a blank page.
Step 3 · two tools you want before writing any code
Extensions → search Vue (Official) → Install.
Without it, a .vue file is grey text with no help and no errors.
Vue DevTools — see every component and its data, live.
create-vue already put it inside your page: the small Vue logo at the bottom, or Alt+Shift+D (Mac ⌥⇧D).
VS Code may offer the extension by itself when you open the folder — "install recommended extensions?" Say yes.
Back to the frameworks deck for one minute
<body> <div id="app"></div> <script type="module" src="/src/main.js"></script> </body>
An empty div. Now open Inspect → Elements: it is full.
This is a client-rendered app.
Everything you see was built in the browser, by JavaScript, after the page arrived. (In dev, Vite adds a script of its own in the head — ignore it.)
Step 4 · find your way around
index.html | the only HTML page — with the empty <div id="app"> |
src/main.js | starts Vue and puts the app into #app |
src/App.vue | the root component — the frame around every page |
src/components/ | reusable pieces: a quote card, a button |
src/views/ | one component per page |
src/router/index.js | which URL shows which view |
public/ | copied as-is: favicon, images, your OG image |
package.json | the shopping list, and the commands dev, build, preview |
node_modules/ | downloaded packages — never edit, never commit |
You will work in src/ almost all the time. Missing a folder? Create it.
Step 4 · how the app starts
<body>
<div id="app"></div>
<script type="module"
src="/src/main.js"></script>
</body>
import { createApp } from 'vue' import App from './App.vue' import router from './router' const app = createApp(App) app.use(router) app.mount('#app')
Your nav.js from lesson 4 did exactly this: getElementById('site-header'), then innerHTML.
Vue does it for the whole page.
Step 4 · bring the stylesheet you already have
style.css from my-site into src/assets/ — create the foldersrc/main.js:import './assets/style.css'
| For the whole site | a CSS file, imported in main.js |
| For one component | <style scoped> inside that .vue file |
Got the example project? Delete its line import './assets/main.css' — that file has the demo's two-column layout, and it will fight yours.
Step 5 · one component, one file, three parts
<script setup> // JavaScript: the data and the logic import { ref } from 'vue' const name = ref('Wuxi') </script> <template> <!-- HTML: what to show --> <h2>Hello from {{ name }}</h2> </template> <style scoped> /* CSS: only for this component */ h2 { color: #2f855a; } </style>
script setup — what the component knows
template — what it shows
style scoped — how it looks, without leaking onto the rest of the page
HTML, CSS and JavaScript — the three things you already know, together in one file because they belong to one piece of the page.
Step 5 · the template, on one slide
| You write | It means |
|---|---|
{{ likes }} | show this value as text |
:href="link" | set an attribute from data — short for v-bind:href |
@click="likes++" | run this when the event happens — short for v-on:click |
v-if="shown" · v-else | only put this on the page if true |
v-for="q in quotes" :key="q.id" | repeat this element for every item |
v-model="search" | an input and a value, kept in sync both ways |
Everything else in a template is HTML. Your semantic markup from lesson 3 goes in unchanged.
Step 5 · only if you got the example project
src/App.vue with the one in step 6 — or just a <RouterView /> for nowsrc/views/HomeView.vue with a heading and a paragraphsrc/components/import './assets/main.css' from src/main.jsIn that order — delete a component while a file still imports it and Vite shows a red error until you fix the import.
Chose "blank project"? Skip this slide.
Step 6 · first, three small pages · create src/views/
<template> <h1>My quote collection</h1> <p>Sentences I keep coming back to.</p> </template>
<template> <h1>About</h1> <p>Who collected these, and why.</p> </template>
<template> <h1>Quotes</h1> <p>Coming in step 7.</p> </template>
A component with only a template is fine. Add a script when it needs data.
The quotes page is a placeholder for now. Step 7 fills it.
Step 6 · then the router · which URL shows which page
import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' import QuotesView from '../views/QuotesView.vue' import AboutView from '../views/AboutView.vue' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ { path: '/', component: HomeView }, { path: '/quotes', component: QuotesView }, { path: '/about', component: AboutView }, ], }) export default router
A fourth page: one new file in src/views, one import, one line in routes.
Step 6 · the frame around every page
<script setup> import { RouterLink, RouterView } from 'vue-router' </script> <template> <header> <nav> <RouterLink to="/">Home</RouterLink> <RouterLink to="/quotes">Quotes</RouterLink> <RouterLink to="/about">About</RouterLink> </nav> </header> <main> <RouterView /> </main> <footer> <p>© 2026 Your Name</p> </footer> </template>
RouterLink — a link that does not reload the page
RouterView — the hole where the current page goes
Header and footer, written once. Lesson 4's nav.html — without the fetch.
Now click between the three pages. The current one's link gets the class router-link-exact-active — style it.
Step 6 · server and client, live
The URL changes to /quotes. But no new HTML page is downloaded — nothing of type "document" appears.
The server was never asked.
The router, in the browser, swapped QuotesView into RouterView. This is client-side routing.
Compare my-site: every link click is a new request, and a new document in the Network tab.
Step 6 · the catch — and it will happen to you after deploying
Live, open yoursite.com/quotes directly. Many hosts answer 404 Not Found.
The server looks for a file called quotes. There is only index.html.
The router lives in the browser — the server has never heard of /quotes.
| Fix 1 · tell the host | "send index.html for every path" — usually a setting called SPA, fallback or rewrite |
| Fix 2 · use the # | createWebHashHistory() → yoursite.com/#/quotes — works on every host |
Why Fix 2 works: the part after # never reaches the server. You learned that in lesson 1, on the URL slide.
Step 7 · the main exercise
Your quote collection —
rebuilt in Vue.
Data in one file. One component for one quote. A list. A search.
Same semantic markup as lesson 3.
Step 7 · first the data, on its own
export const quotes = [ { id: 1, text: 'The best time to plant a tree was twenty years ago. The second best time is now.', author: 'Chinese proverb', source: 'traditional', }, { id: 2, text: 'Learning without thought is labour lost; thought without learning is perilous.', author: 'Confucius', source: 'Analects 2.15', }, { id: 3, text: 'Talk is cheap. Show me the code.', author: 'Linus Torvalds', source: 'Linux kernel mailing list, 2000', }, ]
Then replace these three with your own twenty. The data now lives apart from the HTML.
Step 7 · one quote = one component
<script setup> import { ref } from 'vue' defineProps({ text: String, author: String, source: String, }) const likes = ref(0) </script> <template> <article class="quote"> <blockquote> <p>{{ text }}</p> </blockquote> <footer> <cite>{{ author }}</cite>, <span class="source">{{ source }}</span> </footer> <button @click="likes++">♥ {{ likes }}</button> </article> </template>
defineProps — the three values this card is given
likes — a value the card owns
The template is your lesson 3 markup, with {{ }} where the text was.
Your site-wide CSS for .quote, blockquote and cite still applies. Card-only CSS goes in <style scoped>.
Step 7 · twenty quotes, one component · replaces the placeholder
<script setup> import QuoteCard from '../components/QuoteCard.vue' import { quotes } from '../data/quotes.js' </script> <template> <h1>Quotes</h1> <QuoteCard v-for="q in quotes" :key="q.id" :text="q.text" :author="q.author" :source="q.source" /> </template>
A new quote is one more item in quotes.js. No HTML to copy.
:text="q.text" hands this quote's text to the card. :key tells Vue which card is which.
Step 7 · two kinds of data
Passed in from outside, by the parent.
Read-only inside the component.
Like the attributes of an HTML tag: <img src alt>
Made inside the component with ref().
Changes over time — and the screen follows.
Each card has its own likes. Click one: only that one changes.
Reload the page and the likes are back to zero. State lives in the browser's memory — saving it needs localStorage, or a server.
Step 7 · the payoff · replace QuotesView.vue with this
<script setup> import { ref, computed } from 'vue' import QuoteCard from '../components/QuoteCard.vue' import { quotes } from '../data/quotes.js' const search = ref('') const shown = computed(() => { const s = search.value.toLowerCase() return quotes.filter(q => (q.text + ' ' + q.author).toLowerCase().includes(s)) }) </script> <template> <h1>Quotes</h1> <label>Search <input v-model="search"></label> <p>{{ shown.length }} of {{ quotes.length }}</p> <QuoteCard v-for="q in shown" :key="q.id" :text="q.text" :author="q.author" :source="q.source" /> </template>
Type in the box: the list and the count follow every key. In the script it is search.value; in the template just search.
Stop and look at what you did not write
No addEventListener.
No innerHTML.
No getElementById.
You described the result for any search text. Vue worked out what to change.
Try the same search and count in plain JavaScript tonight — then count the lines. That is the argument for a framework.
Step 8 · build
npm run build npm run preview
dist/ ├── index.html ├── favicon.ico ← everything from public/ └── assets/ ├── index-B8xK2fQa.js ← your components + Vue, in one file └── index-D4mPq1Lr.css ← all your CSS
dist/ is a plain static site. No Vue to install, no Node on the server — just files.
The quotes app: about 90 KB of JavaScript, mostly Vue itself. preview serves dist/ on localhost:4173 — exactly what your visitors will get.
Step 8 · what goes into Git
| File | Commit? |
|---|---|
src/ · public/ · index.html | Yes — your work |
package.json · vite.config.js | Yes — how to build it |
package-lock.json | Yes — the exact versions you tested |
node_modules/ · dist/ | Never — anyone can rebuild them |
create-vue already wrote a .gitignore that leaves out node_modules and dist.
Step 8 · commit and push
git init git add . git commit -m "Start the Vue version of my quote collection"
Then Publish Branch in VS Code, exactly as in the Git deck — a new, public repository.
Before you commit: does Source Control list node_modules or dist? Then something is wrong with .gitignore — stop and ask.
Step 8 · connect your host
| Framework preset | Vite (or Vue) |
| Build command | npm run build |
| Output directory | dist |
| Node.js version | 22 or newer |
Most hosts fill these in when they see Vite. Then every push builds and publishes.
The host runs npm run build on its own machine — build time moves from your laptop to the host.
Read the message, then find it here
| You see | It means |
|---|---|
npm not found / not recognized | terminal opened before Node was installed — restart VS Code |
| running scripts is disabled | Windows PowerShell — the Set-ExecutionPolicy slide |
npm install hangs or times out | the network — the npmmirror slide |
| Port 5173 is in use | a dev server is already running. Vite takes 5174 — read the address |
| a white page | open the Console. Read the first red line |
| Failed to resolve component | you used <QuoteCard> but forgot to import it |
| my changes don't show | you edited dist/, or a different folder is running |
live site: white page, 404s for /assets/… | the site lives in a sub-folder — set base in vite.config.js |
| live site: 404 on reload | client-side routing — the "Reload on /quotes" slide |
The AI has read ten years of Vue tutorials — most of them old
| If the AI writes… | It is… |
|---|---|
new Vue({ el: '#app' }) | Vue 2 — ended December 2023. Will not run. |
Vue.component(…) · this.$set · filters: | Vue 2 only |
import Vue from 'vue' | Vue 2 |
data() { return {…} } · methods: {…} | Options API — valid Vue 3, a different style. Don't mix the two. |
<script setup> · ref() · computed() · defineProps() | What we use ✓ |
Most "it doesn't work" with AI-written Vue is this table. Check the version before you check anything else.
Tell it once, at the start of every chat
This is a Vue 3 project created with create-vue and Vite. Use the Composition API with <script setup>. No Options API, no Vue 2 syntax. Pages live in src/views and are registered in src/router/index.js. Reusable pieces live in src/components. Data lives in src/data. Use semantic HTML: header, nav, main, footer, article, blockquote, cite. Site-wide CSS is in src/assets/style.css. Component CSS goes in <style scoped>. Never put passwords or API keys in this code — it all runs in the browser. Explain every file you change.
The last two lines are for you. A key in Vue code is a published key — and you must be able to explain every line in your project presentation.
The question for your own project
Not required, not extra marks by itself. A reason you can defend is what counts — either way.
Before you leave · check every box
node -v says v22.18+ or v24.12+my-vue-site runs at localhost:5173QuoteCard shows your quotes with v-for, from quotes.jsRouterLink between themnpm run build makes dist/ — and it is committed and pushed, without itWhere to look things up
vuejs.org/guide
in Chinese: cn.vuejs.org · router: router.vuejs.org · build: vite.dev
The official docs are better than any tutorial — and newer than what the AI learned from.