Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't import qs in vite

Tags:

vuejs3

vite

I use vite, ts and vue3. Now I want to use qs.stringfy() to build a url's query, but it panic.

I use yarn add @types/qs to add qs.

My code like this


    import qs from "qs";
    
    qs.stringify(data)

the error is


[plugin:vite:import-analysis] Failed to resolve import "qs" from "src\tools\oauth.ts". Does the file exist?

How can I resolve is?

like image 728
Tian Jiale Avatar asked Sep 15 '25 04:09

Tian Jiale


1 Answers

I believe i found the solution. It seems that @types/qs contains only type declarations (no sources). Installing both qs and @types/qs fixed the problem.

like image 51
Stanislau Listratsenka Avatar answered Sep 17 '25 19:09

Stanislau Listratsenka