DEV Community

Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on

16 3

TIL: TypeScript | Fix "TS2307: Cannot find module 'src' or its corresponding type declarations."

Story

After I updated my package.json and installed all dependencies, my npm run build started failing with

$ npm run build

> vite-vue-typescript-starter@0.0.0 build
> vue-tsc --noEmit && vite build

node_modules/@vue/test-utils/dist/domWrapper.d.ts:5:28 - error TS2307: Cannot find module 'src' or its corresponding type declarations.

5 import { VueWrapper } from 'src';
                             ~~~~~


Found 1 error.
Enter fullscreen mode Exit fullscreen mode

Question

How to fix?

error TS2307: Cannot find module 'src' or its corresponding type declarations.
Enter fullscreen mode Exit fullscreen mode

Answer

This was a tricky one because at a first glance it may seem that I have a typescript problem in project which is technically correct, but actually this is a bug in @vue/test-utils-next library which was introduced in 2.0.0-rc.14 version. Installing 2.0.0-rc.13 or setting skipLibCheck: true in tsconfig.json solves this. For my case, I've chosen the first approach.

What I Learned

  1. skipLibCheck: true > Skip type checking of declaration files.

Links

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
louvani profile image
Louvani

Thank you a lot!!!

Collapse
 
charlesokwuagwu profile image
Charles

this helped me. thanks

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay