microsoft / TypeScript-Vue-Starter

A starter template for TypeScript and Vue with a detailed README describing how to use the two together.
MIT License
4.45k stars 592 forks source link

Can't import Hello.vue component #71

Open brunocasarotti opened 5 years ago

brunocasarotti commented 5 years ago

I'm trying to to run npm run build and I am getting this error

ERROR in ./src/components/Hello.vue (./node_modules/ts-loader!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/Hello.vue)
Module not found: Error: Can't resolve './components/Hello.vue' in 'D:\Projects\typescript-vue-tutorial\src\components'  @ ./src/components/Hello.vue (./node_modules/ts-loader!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/Hello.vue) 2:0-52 10:24-38
 @ ./src/components/Hello.vue
 @ ./src/index.ts

ERROR in D:\Projects\typescript-vue-tutorial\src\index.ts
[tsl] ERROR in D:\Projects\typescript-vue-tutorial\src\index.ts(2,28)
      TS2307: Cannot find module './components/Hello.vue'.

image

I can't figure it out. I am already using "vue-loader": "^14.2.2"

HugoWang3146 commented 5 years ago

Putting the following vue-shim.d.ts declaration file under my ./src directory solves the problem:

declare module "*.vue" {
    import Vue from "vue";
    export default Vue;
}

A solution from https://github.com/vuejs/vue-cli/issues/1198