TypeScript에서 'vue' 'vue-router' 모듈을 찾을 수 없습니다.

 

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/........"]
    }

 

Guess you like

Origin blog.csdn.net/qq_57423665/article/details/131348859