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

Created on 6 Dec 2018  路  11Comments  路  Source: vuejs/vetur

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

need-more-info

Most helpful comment

@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 https://github.com/vuejs/vetur/issues/424.

All 11 comments

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?

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

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?

@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?

@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?

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.

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?)

is this the same issue?
image

@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 https://github.com/vuejs/vetur/issues/424.

@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

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!

Was this page helpful?
0 / 5 - 0 ratings