vite 초기화
Svelte에서 메인으로 사용하는 번들러
npm init vite ./
svelte 선택 후 Enter
│
◆ Select a framework:
│ ○ Vanilla
│ ○ Vue
│ ○ React
│ ○ Preact
│ ○ Lit
│ ● Svelte
│ ○ Solid
│ ○ Qwik
│ ○ Angular
│ ○ Marko
│ ○ Others
JavaScript 선택 후 Enter
◇ Select a framework:
│ Svelte
│
◆ Select a variant:
│ ○ TypeScript
│ ● JavaScript
│ ○ SvelteKit ↗
└
◆ Use rolldown-vite (Experimental)?:
│ ○ Yes
│ ● No
└
npm 설치 후 실행 - Yes 선택 후 Enter
◆ Install with npm and start now?
│ ● Yes / ○ No
└
You are using Node.js 18.15.0. Vite requires Node.js version
20.19+ or 22.12+. Please upgrade your Node.js version.
failed to load config from C:\Users\dq\diquest\study\inflearn\indiecoder-svelte-basic\vite.config.js
error when starting dev server:
file:///C:/Users/dq/diquest/study/inflearn/indiecoder-svelte-basic/node_modules/@sveltejs/vite-plugin-svelte/src/utils/log.js:4
import { styleText } from 'node:util';
^^^^^^^^^
SyntaxError: The requested module 'node:util' does not provide an export named 'styleText'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
PS C:\Users\dq\diquest\study\inflearn\indiecoder-svelte-basic> npm init [email protected] ./
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dq\AppData\Local\npm-cache\_logs\2025-11-22T07_57_35_418Z-debug-0.log
강의에서 나오는 설치방법은 vite 최신기준으로 svelte가 설치되기 때문에 node 18.15.0에서 지원하지 않는 라이브러리인 styleText가 설치되지 않으므로 오류가 발생한다. 강의에서 사용중인 svelte 버전3이다.
{
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.0.0",
"svelte": "^3.54.0",
"tinro": "^0.6.12",
"vite": "^4.0.0"
}
}
기존 svelte devDependencies 제거
npm remove vite @sveltejs/vite-plugin-svelte svelte
혹은 마지막 옵션인 Install with npm and start now?를 No로 설치한다
◆ Install with npm and start now?
│ ○ Yes / ● No
└
강의 버전으로 재설치
npm install -D [email protected] @sveltejs/[email protected] [email protected]
{
"compilerOptions": {
"moduleResolution": "Node",
"target": "ESNext",
"module": "ESNext",
/**
* svelte-preprocess cannot figure out whether you have
* a value or a type, so tell TypeScript to enforce using
* `import type` instead of `import` for Types.
*/
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"resolveJsonModule": true,
/**
* To have warnings / errors of the Svelte compiler at the
* correct position, enable source maps by default.
*/
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
/**
* Typecheck JS in `.svelte` and `.js` files by default.
* Disable this if you'd like to use dynamic types.
*/
"checkJs": true
},
/**
* Use global.d.ts instead of compilerOptions.types
* to avoid limiting type declarations.
*/
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
}
let count = $state(0)을 let count = 0 으로 수정<button onclick={increment}>를 <button on:click={increment}> 으로 수정import { mount } from 'svelte'
import './app.css'
import App from './App.svelte'
const app = mount(App, {
target: document.getElementById('app'),
})
export default app
import './app.css'
import App from './App.svelte'
const app = new App({
target: document.getElementById('app'),
})
export default app