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

Taro v1.3.12 运行 taro doctor 报错Failed to load plugin react-hooks: Cannot find module 'eslint-plugin-react-hooks' #4083

Closed
nyrf opened this issue Aug 6, 2019 · 8 comments

Comments

@nyrf
Copy link

nyrf commented Aug 6, 2019

问题描述
用taro 1.3.12 新建项目,运行taro doctor, 出现⠋ 正在诊断项目...(node:61843) UnhandledPromiseRejectionWarning: Error: Failed to load plugin react-hooks: Cannot find module 'eslint-plugin-react-hooks' 错误

报错信息

❯ taro doctor
👽 Taro v1.3.12

⠋ 正在诊断项目...(node:61843) UnhandledPromiseRejectionWarning: Error: Failed to load plugin react-hooks: Cannot find module 'eslint-plugin-react-hooks'
Require stack:
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/node_modules/eslint/lib/config/plugins.js
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/node_modules/eslint/lib/config.js
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/node_modules/eslint/lib/cli-engine.js
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/node_modules/eslint/lib/api.js
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/dist/doctor/eslintValidator.js
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/dist/doctor/index.js
- /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/bin/taro-doctor
Referenced from: /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/node_modules/eslint-config-taro/index.js
Referenced from: /Users/nyrf/.config/nvm/12.6.0/lib/node_modules/@tarojs/cli/dist/doctor/validatorEslintrc.js

系统信息

Taro CLI 1.3.12 environment info:
    System:
      OS: macOS 10.14.4
      Shell: 3.0.2 - /usr/local/bin/fish
    Binaries:
      Node: 12.6.0 - ~/.config/nvm/12.6.0/bin/node
      Yarn: 1.12.1 - /usr/local/bin/yarn
      npm: 6.9.0 - ~/.config/nvm/12.6.0/bin/npm
    npmPackages:
      @tarojs/components: 1.3.12 => 1.3.12
      @tarojs/plugin-babel: 1.3.12 => 1.3.12
      @tarojs/plugin-csso: 1.3.12 => 1.3.12
      @tarojs/plugin-sass: 1.3.12 => 1.3.12
      @tarojs/plugin-uglifyjs: 1.3.12 => 1.3.12
      @tarojs/router: 1.3.12 => 1.3.12
      @tarojs/taro: 1.3.12 => 1.3.12
      @tarojs/taro-alipay: 1.3.12 => 1.3.12
      @tarojs/taro-h5: 1.3.12 => 1.3.12
      @tarojs/taro-qq: 1.3.12 => 1.3.12
      @tarojs/taro-quickapp: 1.3.12 => 1.3.12
      @tarojs/taro-swan: 1.3.12 => 1.3.12
      @tarojs/taro-tt: 1.3.12 => 1.3.12
      @tarojs/taro-weapp: 1.3.12 => 1.3.12
      @tarojs/webpack-runner: 1.3.12 => 1.3.12
      eslint-config-taro: 1.3.12 => 1.3.12
      eslint-plugin-taro: 1.3.12 => 1.3.12
      nerv-devtools: ^1.4.0 => 1.4.3
      nervjs: ^1.4.0 => 1.4.3
      stylelint-config-taro-rn: 1.3.12 => 1.3.12
      stylelint-taro-rn: 1.3.12 => 1.3.12
@taro-bot
Copy link

taro-bot bot commented Aug 6, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@nyaapass
Copy link

nyaapass commented Aug 6, 2019

+1, 更新到 1.3.12 后同样出现了该问题

  • OS: Linux 4.4 Ubuntu 18.04.3 LTS (WSL in Windows 10)
  • Node: 10.16.1
  • Yarn: 1.17.3
  • npm: 6.9.0

@Chris533
Copy link

直接关了呀? 问题依然存在呢

@nyaapass
Copy link

@luckyadam @yuche

更新到 v1.3.13 后该问题解决了, 但是更新到 v1.3.14 后运行 taro doctor 又出现了类似的问题:

⠋ 正在诊断项目...(node:8972) UnhandledPromiseRejectionWarning: Error: Failed to load plugin 'react-hooks' declared in '--config » eslint-config-taro » /路径/yarn/global/node_modules/@tarojs/cli/node_modules/eslint-config-taro/rules/jsx.js': Cannot find module 'eslint-plugin-react-hooks'

@MirGhojam
Copy link

此问题什么时候修复,有没有应急措施?

@nyaapass
Copy link

nyaapass commented Aug 23, 2019

此问题什么时候修复,有没有应急措施?

taro init 新建一个空项目再运行 taro doctor 是正常的, 和现有项目比对后发现项目里多了 "eslint-plugin-react-hooks": "^1.6.1" 这个依赖, 在现有项目里加上该依赖后 taro doctor 即可恢复正常. (更新 cli 后虽然 cli 新增了 eslint-plugin-react-hooks 这个依赖, 但是项目里并没有)

但是既然 doctor 本身是有检查依赖这个功能, 还是建议后续对类似这种情况先检测一下, 给一个人性化的提示更加合适. 或者在 taro update project 的时候对类似情况做处理.

@nyaapass
Copy link

nyaapass commented Aug 23, 2019

学习了一下检查依赖这一块的代码, 其实是有检查是否安装依赖的, 不过是通过 npm-check 来检查 package.json 里的依赖是否都已经安装到了路径中.

建议: 像 cli/templates/default 若是新引入了影响 taro doctor 的依赖 (尤其是 eslint 相关) 这种情况, 可以维护一份新引入的依赖列表, 在运行 pkgsNotInstalled() 的时候同时检查该列表里的依赖是否已安装.

@MirGhojam
Copy link

@nyaapass 谢了哈

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

4 participants