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

vetur script validation error: cannot find module, but can use this module, no problem #1017

Open
PANYUXIN6 opened this issue Dec 6, 2018 · 11 comments

Comments

@PANYUXIN6
Copy link

the validation of script has a bug
if i import a module which i has developed , it will tell me cannot find this module, bug i can use it,when the script's lang is ts
image
image

@octref
Copy link
Member

octref commented Dec 12, 2018

Where does @kk/kk-user-sdk resolve to? A local file or a NPM module?

Can you try to give a minimal repro out of https://github.com/octref/veturpack?

@PANYUXIN6
Copy link
Author

Where does @kk/kk-user-sdk resolve to? A local file or a NPM module?

Can you try to give a minimal repro out of https://github.com/octref/veturpack?

it's a NPM module in Private npm Registries

@octref
Copy link
Member

octref commented Dec 13, 2018

Where does it resolves to? Vetur should try node_modules/@kk/kk-user-sdk. Do you have other webpack rules or path mapping for TS?

@jgilchrist
Copy link

@octref Just wanted to add on that I've experienced this issue. In this case, the dependency is in node_modules in a parent directory as it's a dependency used by more than one package in a yarn workspace. Could that be causing it?

@octref
Copy link
Member

octref commented Mar 27, 2019

@jgilchrist I thought yarn workspace symlink local node_modules so they refer to the top-level deps. Can you share roughly how your folders look like, and on which folder are you opening Vetur?

@jgilchrist
Copy link

Sure thing - the folder structure is roughly:

/
    - node_modules/     <- this contains all the dependencies
    - packages/
        - project1/
             - node_modules/       <- this is empty
        - project2/
             - node_modules/       <- this is empty
        - shared_library/

I'm opening Vetur on the top level folder and working on all three projects, but am getting the 'cannot find module' in all three.

@jgilchrist
Copy link

This comment suggests that this is expected and that all dependencies that can be hoisted to the workspace root will be. Is it possible that this is causing the issues (i.e. Vetur isn't checking the workspace root for these dependencies?)

@kinghat
Copy link

kinghat commented Apr 25, 2019

is this the same issue?
image

@octref
Copy link
Member

octref commented Apr 26, 2019

@k1nghat Yours is a different issue.

@jgilchrist Sorry for late response, Vetur only searches for the node_modules in your workspace top level now. See #424.

@Edwardenis
Copy link

@jgilchrist Sorry for late response, Vetur only searches for the node_modules in your workspace top level now. See #424.

Thanks @octref for that information. I didn't know that I cannot have my SPA in a subfolder.
I've been getting that error with vetur for like 11 months and did't know how to get rid of it.

Besides, a was getting dependency resolution error using a CI pipeline in Azure DevOps, the exact same error that @yinX0412 was talking about.

Devops error

After your comment I tried to move all vue files to root folder and it is working now :D

I've been digging around for like 5 hours to solve that xD. Thanks a lot <3

@paparent
Copy link

Hi!

I had the same issue here. Cannot find module ... Vetur(2307).

I'm in a mono-repo setup too, using Yarn workspaces, so at first, I was thinking something around node_modules.

It turns out that if I added type definition (types property in the package), create the .d.ts files, the error is gone and it works perfectly!

Now, I just have to find a way to make rollup export typescript declaration properly, but that's another story.

I hope it helps!

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

6 participants