vscode node.js IntelliSense和linting问题

发布于 2025-02-12 06:18:42 字数 982 浏览 1 评论 0原文

一段时间以来,我在Vscode上有几个烦人的问题。我使用1.68.1版,并在macOS上在Node.js上工作。出于此测试的目的,我创建了一个设置,如下所示:

projectDir
 - package.json
 - logger.js
 - index.js

package.json在这里无关紧要,但其他两个文件如下。

logger.js

const logger = (msg) => {
    console.log(msg);
}

module.exports = { logger };

index.js

const { logger } = require("./logger");

someFunc();
logger("Hello!");

这是我正在努力的两件事:

  1. 未标记未标记的功能。例如,在index.js中,有一个调用somefunc(),但VSCODE没有任何问题。未宣布的变量是一样的。如果我在文件中添加a = zz;,则没有警告。
  2. 如果我关闭logger.js文件,则无法自动完成导入。我的意思是,如果打开logger.js文件,那么我可以输入“ logger”并从建议列表中选择导入,但是如果文件已关闭,则不会发生。我不确定这是否应该是应该的,但是一旦项目中有10-15个文件,这很烦人,因为我需要在VScode“意识到”其出口之前手动打开它们。

抱歉,如果这一切都很愚蠢,但是这两件事一直在影响我的工作流程。请随时要求提供更多信息!

I have a couple of annoying issues with VSCode for some time. I'm on version 1.68.1 and working in Node.js on MacOS. For the purposes of this test, I created a setup as follows:

projectDir
 - package.json
 - logger.js
 - index.js

The package.json is inconsequential here but the other two files are as follows.

logger.js

const logger = (msg) => {
    console.log(msg);
}

module.exports = { logger };

index.js

const { logger } = require("./logger");

someFunc();
logger("Hello!");

Here are the two things I'm struggling with:

  1. Unimported functions are not flagged. For example, there's a call to someFunc() in index.js but VSCode has no problems with it. It's the same with undeclared variables. If I add a = zz; in the file, there are no warnings.
  2. If I close the logger.js file, I can't autocomplete the import. What I mean is, if the logger.js file is open, then I can just type "logger" and select the import from the suggestions list, but it doesn't happen if the file is closed. I'm not sure if this is how it's supposed to be, but it's very annoying once there are more than 10-15 files in the project as I need to manually open them before VSCode becomes "aware" of their exports.

Sorry if this is all silly, but these two things have been impacting my workflow. Please feel free to ask for more info!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文