import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
힌트: 'vue-router' 모듈을 찾을 수 없습니다. "moduleResolution" 옵션을 "node"로 설정하시겠습니까, 아니면 "paths" 옵션에 별칭을 추가하시겠습니까? ts(2792)
옵션 1
선언 파일 가져오기
TypeScript 가져오기로 변환을 시작하면 Cannot find module 'foo'. 오류가 발생할 수 있습니다. 문제
는 코드 기반을 설명하는 선언 파일이 없다는 것입니다. 다행히 이것은 매우 간단합니다. TypeScript가 lodash 패키지가 없다고 불평하면
그냥 할 수 있습니다.
npm install -s @types/lodash
commonjs
모듈 모듈 옵션을 사용하지 않는 경우 moduleResolution
옵션을 로 설정 해야 합니다 node
.
그런 다음 가져오기를 수행 lodash
하고 정확한 자동 완성을 얻을 수 있습니다.
여기에 언급된 commonjs 옵션은 tsconfig.json 파일의 "module" 속성을 참조합니다.
해결 방법 2:
tsconfig.json 파일
"paths": {
"vuex": ["node_modules/vuex/types/index.d.ts"]
"vue-router": ["node_modules/........"]
}