dva-init 初始化项目升级, package.json报错
image.png

react-18 报错

dva-18-error.png
ncu -u 升级 package.json最新报错

  • index.js:2177 Warning: Please use require("history").createHashHistory instead of require("history/createHashHistory"). Support for the latter will be removed in the next major release.
    • history的错误


eslint@8报错

“eslint”: “^8.12.0”, 报错
The issue is with ESLint version 6.x. If upgrading Webstorm is not an option for you, you have to downgrade to ESLint version 5:
解决参考
https://stackoverflow.com/questions/57944468/webstorm-2018-1-4-eslint-typeerror-this-cliengine-is-not-a-constructor

  • Failed to compile

./src/index.js
Module build failed: TypeError: eslint.CLIEngine is not a constructor

  • 解决:降级 eslint版本为 @5
    1. npm install eslint@5 eslint-plugin-flowtype@5 --save-dev

react-17 package.json

  1. {
  2. "private": true,
  3. "scripts": {
  4. "start": "roadhog server",
  5. "build": "roadhog build",
  6. "test": "roadhog test",
  7. "lint": "eslint --ext .js src test",
  8. "precommit": "npm run lint"
  9. },
  10. "dependencies": {
  11. "dva": "^2.4.1",
  12. "react": "^17.0.2",
  13. "react-dom": "^17.0.2"
  14. },
  15. "devDependencies": {
  16. "babel-plugin-dva-hmr": "^0.4.2",
  17. "eslint": "^5.16.0",
  18. "eslint-config-umi": "^1.6.0",
  19. "eslint-plugin-flowtype": "^5.10.0",
  20. "eslint-plugin-import": "^2.25.4",
  21. "eslint-plugin-jsx-a11y": "^6.5.1",
  22. "eslint-plugin-react": "^7.29.4",
  23. "husky": "^7.0.4",
  24. "redbox-react": "^1.6.0",
  25. "roadhog": "^2.5.0-beta.4"
  26. }
  27. }

总结

  1. 不建议使用 dva,使用 umijs3.x
  2. 自己封装维护脚手架,这样可以确保技术栈是最新的