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

[求助]eslint 一直报找不到@babel/plugin-proposal-decorators #122

Open
dadazhouRenee opened this issue Feb 11, 2022 · 7 comments
Open

Comments

@dadazhouRenee
Copy link

node: 12.22.0
yarn: 1.22.17
farbic version: 2.6.6
依赖:

"devDependencies": {
    "@ant-design/compatible": "^1.0.8",
    "@types/react": "^16.4.11",
    "@types/react-dom": "^16.0.6",
    "@umijs/fabric": "2.6.6",
    "@umijs/plugin-qiankun": "^2.35.2",
    "@umijs/preset-react": "^1.8.4",
    "cross-env": "^5.1.1",
    "cross-port-killer": "^1.0.1",
    "enzyme": "^3.4.4",
    "eslint": "^7.30.0",
    "gh-pages": "^1.2.0",
    "lint-staged": "^12.3.3",
    "merge-umi-mock-data": "^0.0.3",
    "mockjs": "^1.0.1-beta3",
    "prettier": "2.3.2",
    "pro-download": "^1.0.1",
    "stylelint": "^14.5.0",
    "umi": "^3.5.20"
  }

编辑器报错

Parsing error: Cannot find module '@babel/plugin-proposal-decorators'
Require stack:
- D:\xxx\node_modules\@babel\core\lib\config\files\plugins.js
- D:\xxx\node_modules\@babel\core\lib\config\files\index.js
- D:\xxx\node_modules\@babel\core\lib\index.js
- D:\xxx\node_modules\@babel\eslint-parser\lib\worker\babel-core.cjs
- D:\xxx\node_modules\@babel\eslint-parser\lib\worker\handle-message.cjs
- D:\xxx\node_modules\@babel\eslint-parser\lib\client.cjs
- D:\xxx\node_modules\@babel\eslint-parser\lib\index.cjs
- D:\xxx\node_modules\@eslint\eslintrc\lib\config-array-factory.js
- D:\xxx\node_modules\@eslint\eslintrc\lib\index.js
- D:\xxx\node_modules\eslint\lib\cli-engine\cli-engine.js
- D:\xxx\node_modules\eslint\lib\cli-engine\index.js
- D:\xxx\node_modules\eslint\lib\api.js

但是 node_modules可以找到plugin-proposal-decorators
1644560262(1)
请问这是什么原因呢

@gary-Shen
Copy link

+1

@ipoto
Copy link

ipoto commented Mar 24, 2022

在tsconfig.json的include加上.eslintrc.js,"include": ["mock//*", "src//", "config/**/", ".umirc.ts", "typings.d.ts", ".eslintrc.js"],

@yunsii
Copy link
Contributor

yunsii commented Apr 23, 2022

我现在是 JS 项目会这样,令人窒息

@yunsii
Copy link
Contributor

yunsii commented Apr 23, 2022

终于搞懂了,我手动按着依赖往上一层层找确实找不到依赖,果然代码是不会骗人的 _(:з」∠)_ 研究了很久,发现因为我是用的 pnpm,而 pnpm 默认创建的是半严格的 node_modules 导致的问题,可通过配置 shamefully-hoist 暴力解决,我目前配置的是 public-hoist-pattern[]=*@babel*

@Renderz
Copy link
Contributor

Renderz commented May 26, 2022

public-hoist-pattern[]=@babel

直接配shamefully-hoist=true再重装依赖好像就可以了

@yunsii
Copy link
Contributor

yunsii commented May 26, 2022

public-hoist-pattern[]=@babel

直接配shamefully-hoist=true再重装依赖好像就可以了

这是最暴力的解决方案,倒是看到不少开源库也是这么干的

@superbogy
Copy link

+1

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

6 participants