【问题标题】:VSCode does not detect import path from node_modulesVSCode 未检测到来自 node_modules 的导入路径
【发布时间】:2021-12-16 03:24:24
【问题描述】:

我安装了多个包,比如:

"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/react-hooks": "^7.0.2",

当我这样导入时(* 是从这些库中导出的东西):

import * from '@testing-library/jest-dom' // ok, vscode knows this and even auto imports
import * from '@testing-library/react' // vscode doesn't detect this
import * from '@testing-library/react-hooks' // vscode doesn't know what this is

我不知道为什么,因为它们被添加到package.json并正常安装。使用这些库的代码可以 100% 正常工作。问题是 VSCode 无法使用它们,没有路径自动导入,没有建议,没有参考......

【问题讨论】:

    标签: visual-studio-code node-modules


    【解决方案1】:

    请检查您是否为它安装了正确的库。如果没有尝试安装它或再次检查以防您尚未安装。如果问题仍然存在,请尝试重新下载 vs 代码

    【讨论】:

    • 从这些库中导出的所有函数都可以正常工作。在这个项目之前我从来没有遇到过这个问题。
    猜你喜欢
    • 2022-10-05
    • 2020-05-29
    • 2021-07-16
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 2018-06-27
    • 2022-08-19
    • 2020-05-15
    相关资源
    最近更新 更多