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

Vite+Vue3项目配置了type依旧在运行和打包时报错 #116

Open
xxwangkaimin opened this issue Jan 26, 2025 · 5 comments
Open

Vite+Vue3项目配置了type依旧在运行和打包时报错 #116

xxwangkaimin opened this issue Jan 26, 2025 · 5 comments

Comments

@xxwangkaimin
Copy link

type配置:

Image

main.ts引入时报错,但是不影响运行:

Image

打包时报错导致打包失败:

Image

@YiMo1
Copy link

YiMo1 commented Feb 14, 2025

在它的源package.json文件中,exports字段新增下面代码

"./client": {
  "types": "./client.d.ts"
}

@xxwangkaimin
Copy link
Author

@YiMo1 所以说要改源码?

@YiMo1
Copy link

YiMo1 commented Feb 14, 2025

@YiMo1 所以说要改源码?

看样子这个项目已经停止维护了,如果你是多设备或者多人协同工作的话,可以通过修改源码并打补丁的方式去解决这个问题。

你也可以在issue中寻找其他和你一样的问题的人,看看他们有没有fork此仓库并作出修改的版本且发布到了npm上,如果有的话,你可以使用其他人的npm包。

@steavengong
Copy link

steavengong commented Feb 24, 2025

我也刚碰到这个问题
我在 tsconfig.json 中,compilerOptions 节点修改moduleResolution:"node"
同时在 vite-env.d.ts 中增加
/// <reference types="vite-plugin-svg-icons/client" />

@YiMo1
Copy link

YiMo1 commented Feb 26, 2025

我也刚碰到这个问题 我在 tsconfig.json 中,compilerOptions 节点修改moduleResolution:"node" 同时在 vite-env.d.ts 中增加 /// <reference types="vite-plugin-svg-icons/client" />

如果是面向浏览器的项目的话,moduleResolution一般是Bundler而不是node,为了解决这个问题而修改这个属性可能会导致其它意想不到的错误,并不推荐。

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

No branches or pull requests

3 participants