M

Vue + TypeScript 설치 본문

Vue

Vue + TypeScript 설치

M_master 2024. 8. 11. 14:32

1. Node 설치

brew node install

 

> node -v 명령어로 설치 확인

node -v

 

2. Vue 설치

- vue 2.x

npm install vue-cli -global

 

- vue 3.x

npm install -g @vue/cli

 

설치 시 오류 관련

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/@vue
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@vue'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/@vue'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

 

해결방법

1. sudo를 통한 해결

보안이슈, 폴더 꼬임 등 문제 발생 가능성이 있음

 

또 다른 오류

Error: command failed: npm install --loglevel error --legacy-peer-deps
Error: command failed: npm install --loglevel error --legacy-peer-deps
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@vue/cli/lib/util/executeCommand.js:138:16)
    at ChildProcess.emit (node:events:520:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

 

- 해결방법

npm 캐시 지우기

sudo npm cache clear --force

 

3. vue 프로젝트 생성

vue create [project-name]

 

- 옵션 선택

# 옵션 선택

? Please pick a preset: Manually select features
? Check the features needed for your project: Choose Vue version, Babel, TS, Router, Vuex, Linter
? Choose a version of Vue.js that you want to start the project with 3.x
? Use class-style component syntax? Yes
? Use Babel alongside TypeScript (required for modern mode, auto-detected polyfills, transpiling JSX)? Yes
? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
? Pick a linter / formatter config: Prettier
? Pick additional lint features: Lint on save
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
728x90

'Vue' 카테고리의 다른 글

[Vue3] ref와 reactive 차이점  (0) 2024.08.29
[vue3] v-model 내장 수정자  (0) 2024.08.27
[Vue3] defineModel  (0) 2024.08.27
Vue 관련 패키지 추천  (0) 2024.08.15