小编Dig*_*eze的帖子

为什么 VS Code 从“hoist-non-react-statics/node_modules/@types/react”导入

我最近将我的 React 存储库移至 下的单个 Mono 存储库中/client。我使用yarn install安装了node_modules/client

VS code intellisense 建议我在导入像和 之类的反应钩子时导入 fromhoist-non-react-statics/node_modules/@types/react而不是 from 。当我使用编译时这会导致以下错误reactuseEffectuseRefyarn start

找不到模块:无法解析“hoist-non-react-statics/node_modules/@types/react”

我的 package.json 中没有“hoist-non-react-statics”作为依赖项。我的 package.json 依赖项如下:

"dependencies": {
    "@auth0/auth0-react": "^1.6.0",
    "@hookform/resolvers": "^2.7.1",
    "@reduxjs/toolkit": "^1.6.1",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/jest": "^24.0.0",
    "@types/node": "^12.0.0",
    "@types/qs": "^6.9.7",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/react-redux": "^7.1.7",
    "@types/react-slider": "^1.3.1",
    "@types/react-table": "^7.7.2",
    "clsx": "^1.1.1",
    "final-form": "^4.20.2",
    "final-form-calculate": "^1.3.2",
    "lodash": "^4.17.21",
    "qs": "^6.10.1",
    "rc-checkbox": "^2.3.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-final-form": "^6.5.3",
    "react-hook-form": …
Run Code Online (Sandbox Code Playgroud)

intellisense node-modules reactjs visual-studio-code

28
推荐指数
2
解决办法
1万
查看次数