Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find module about non-relative path #545

Closed
evvil opened this issue Nov 15, 2017 · 7 comments
Closed

Can't find module about non-relative path #545

evvil opened this issue Nov 15, 2017 · 7 comments

Comments

@evvil
Copy link

evvil commented Nov 15, 2017

Info

  • Platform: Win 10
  • Vetur version: 0.11.3
  • VS Code version: 1.18.0
  • Typescript: 2.6.1
  • Vue: 2.5.3

Problem

Hi, I use typescript to write the .vue file. And vetur always alert this error.
I have tried all of the solution on Google, but failed all the time.
I have tried all the combination of resolve of the tsconfig.json and reinstall yarn the package of the project.
And I have read the #423 , however, i can't find the solution working for me.

image
image

//tsconfig.json
{
    "compilerOptions":{
        "moduleResolution": "node",
        "baseUrl": ".",
        "paths": {
           "@/*": ["src/*"]
         },
    }
}
//list.vue
<template/>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import Msg from "@/utils/msg";
<script/>
//msg.ts
/**
 * Created by vtroo on 2017/7/13.
 */
import {Message} from 'element-ui';
export default (type, err: string) => {
  return Message({
    message: err,
    type: type,
    duration: 2 * 1000,
    showClose: true
  });
}
//global.d.ts
declare module "*.vue" {
    import Vue from 'vue'
    export default Vue
}
declare module "*.html" {
    let template: string;
    export default template;
}
# I have delete some unnecessary files
.
├── appinfo
├── build.sh
├── home.html
├── package.json
├── package-lock.json
├── README.md
├── src
│   ├── api
│   │   ├── category
│   │   │   ├── allCategory.ts
│   │   │   ├── apiDetail.ts
│   │   │   └── myCategory.ts
│   │   └── tools
│   │       ├── apiTest.ts
│   │       └── serviceQuery.ts
│   ├── App.vue
│   ├── components
│   │   ├── common
│   │   ├── test.vue
│   │   ├── tools
│   │   │   └── treeview
│   │   │       ├── TreeViewItemValue.vue
│   │   │       ├── TreeViewItem.vue
│   │   │       └── TreeView.vue
│   │   └── Welcome.vue
│   └── utils
│       └── msg.ts
├── tsconfig.json
├── tslint.json
├── yarn-error.log
└── yarn.lock

Reproducible Case

I don't know why vetur can't read the tsconfig.json and resolve the non-relative path, did I do something wrong?

@HerringtonDarkholme
Copy link
Member

Can you provide a repo for this?

On the other hand, can you import non relative path in typescript file?

@evvil
Copy link
Author

evvil commented Nov 15, 2017

@HerringtonDarkholme this project is here

yarn

yarn run dev

Yes, I can import other file.

@evvil
Copy link
Author

evvil commented Nov 15, 2017

do you nedd backend service?@HerringtonDarkholme

@HerringtonDarkholme
Copy link
Member

I cannot reproduce this problem.

screenshot from 2017-11-15 20-57-01

Everything seems to work fine.

@evvil
Copy link
Author

evvil commented Nov 15, 2017

@HerringtonDarkholme My mistake, after exit and restart my vscode, all the problem goes away.

As far as I'm concerened, the problem may be caused by the vscode, because I hava a couple of days not closing the vscode. And the tsconfig.json is not right before.

Thanks anyway.

@HerringtonDarkholme
Copy link
Member

HerringtonDarkholme commented Nov 15, 2017

wow, didn't think vscode can be such a long-life process :)

Anyway, I think this issue has been solved.

BTW, @types/vue isn't needed and probably will cause errors. Vue2 has included typing in its distribution. You probably need to delete @types from deps.

@evvil
Copy link
Author

evvil commented Nov 15, 2017

yes, can't agree more, MS' product needs rebooting
Hope this config can help others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants