unplugin-element-plus
unplugin-element-plus copied to clipboard
Cannot find module 'unplugin-element-plus/vite' or its corresponding type declarations.
VsCode Version: 1.77.1 Node.js: 16.14.2 OS: Windows10 x64 10.0.19045
"vite": "^4.2.1" "unplugin-element-plus": "^0.7.0" "typescript": "^4.9.5"
在vite中使用:
import ElementPlus from "unplugin-element-plus/vite";
报了一个 typescript 错误:
Cannot find module 'unplugin-element-plus/vite' or its corresponding type declarations.
我也遇到了同样的错误,求解决方式
@sjqw @yxb94616 我也遇到了这个问题,暂时没找到很好的解决方案,但我找到了别的办法,因为我之前的项目这么写是没问题的,所以我查看了版本号,之前的安装的是0.4.1的,所以如果你也不知道怎么解决,安装0.4.1版本可能是一个不错的办法,或者直接使用// @ts-ignore
忽略这一行的报错
npm i [email protected] -D
// or
// @ts-ignore
import ElementPlus from 'unplugin-element-plus/vite'
同上,也遇到了这个问题
同上,我也遇到了这个问题
OS: Windows10 x64 IDE:WebStorm 2023.1 Node:18.13.0
vite:4.2.1 typescript:5.0.2 unplugin-element-plus:0.7.0
@sjqw @heyongsheng @L-T-G @skyclouds2001 已找到解决这个问题的方法,在你使用的 tsconfig*.json 下的 compilerOptions 中添加如下属性/值:
"moduleResolution": "bundler"
错误解决后,引入插件使用的话,插件必须传参数,这个是插件的问题,目前我传的是
useSource: true
https://github.com/element-plus/unplugin-element-plus#usesource
造成这个错误的原因是因为 typescript 的模块解析策略问题,有兴趣可以了解一下,推荐几篇文章:
https://www.typescriptlang.org/docs/handbook/module-resolution.html https://juejin.cn/post/7221551421833314360
+1
"moduleResolution": "bundler" 使用这个配置后,从element-plus导出的组件类型找不到了。 import type { FormInstance } from 'element-plus' // 模块"element-plus"没有导出的成员"FormInstance"
"moduleResolution": "bundler" 使用这个配置后,从element-plus导出的组件类型找不到了。 import type { FormInstance } from 'element-plus' // 模块"element-plus"没有导出的成员"FormInstance"
我这里没有这个问题呐
"moduleResolution": "bundler" 使用这个配置后,从element-plus导出的组件类型找不到了。 import type { FormInstance } from 'element-plus' // 模块"element-plus"没有导出的成员"FormInstance"
我这里没有这个问题呐
你的package.json中有type:"module"吗
"moduleResolution": "bundler" 使用这个配置后,从element-plus导出的组件类型找不到了。 import type { FormInstance } from 'element-plus' // 模块"element-plus"没有导出的成员"FormInstance"
我这里没有这个问题呐
你的package.json中有type:"module"吗
没有呢
"moduleResolution": "bundler" 使用这个配置后,从element-plus导出的组件类型找不到了。 import type { FormInstance } from 'element-plus' // 模块"element-plus"没有导出的成员"FormInstance"
我这里没有这个问题呐
你的package.json中有type:"module"吗
没有呢
难搞,我已经通过回退至0.4.1解决了
同样的问题,我是通过将项目ts版本降级解决的,当我把TypeScript升级到5.0.4后就出现了这个问题,此时,Webstorm下方提示当前项目为TypeScript 5.0.4,没有识别到这是Vue项目,不仅是这个插件报错,连导入.vue文件都报错。
我将TypeScript版本回退到4.8.4后,一切都恢复了正常,WebStorm正确认识到,这是一个使用TypeScript的Vue项目,而不是一个纯粹的TypeScript项目
just add // @ts-ignore
just add // @ts-ignore
if using @ts-ignore to disable this ts error, @ts-expect-error is much better
just add // @ts-ignore
if using @ts-ignore to disable this ts error, @ts-expect-error is much better
Yeah!👍 we expected for more better! @element-bot #unplugin-element-plus