vscode node.js IntelliSense和linting问题
一段时间以来,我在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!");
这是我正在努力的两件事:
- 未标记未标记的功能。例如,在
index.js
中,有一个调用somefunc()
,但VSCODE没有任何问题。未宣布的变量是一样的。如果我在文件中添加a = zz;
,则没有警告。 - 如果我关闭
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:
- Unimported functions are not flagged. For example, there's a call to
someFunc()
inindex.js
but VSCode has no problems with it. It's the same with undeclared variables. If I adda = zz;
in the file, there are no warnings. - If I close the
logger.js
file, I can't autocomplete the import. What I mean is, if thelogger.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论