当前位置:   article > 正文

解决vite-plugin-eslint引入type类型报错的问题_无法找到模块“vite-plugin-eslint”的声明文件

无法找到模块“vite-plugin-eslint”的声明文件
  1. 无法找到模块“vite-plugin-eslint”的声明文件。“xxxx”隐式拥有 "any" 类型。
  2. There are types at 'xxxxx/index.d.ts',
  3. but this result could not be resolved when respecting package.json "exports".
  4. The 'vite-plugin-eslint' library may need to update its package.json or typings.ts(7016)

目前看npm包更新时间在一年前,报错原因可能是由于typescript变更导致依赖包package.json不匹配。

看了github上各个大神提出的解决方案,有点看不懂,搞了很久才大致摸索出了,所以分享下
————————————————

思路是使用patch-package修改vite-plugin-eslint包源文件

patch-package具体使用方法可以参考:

【patch-package】修改node_modules下的依赖包源码-CSDN博客

  1. pnpm i patch-package
  2. pnpm patch vite-plugin-eslint
  3. pnpm patch-commit xxxxx地址
修改内容如下:

1.复制一份index.js 改为 index.cjs

2.修改package.json文件内容

  1. "main": "./dist/index.cjs",
  2. "module": "./dist/index.mjs",
  3. "types": "./dist/index.d.ts",
  4. "exports": {
  5. ".": {
  6. "require": "./dist/index.cjs",
  7. "import": "./dist/index.mjs",
  8. "types": "./dist/index.d.ts"
  9. }
  10. },
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/712017
推荐阅读
相关标签
  

闽ICP备14008679号