无法解析“${workspaceFolder}".请打开一个文件夹.在 Visual Studio 代码上 [英] '${workspaceFolder}' can not be resolved. Please open a folder.' on Visual Studio Code

查看:302
本文介绍了无法解析“${workspaceFolder}".请打开一个文件夹.在 Visual Studio 代码上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道您是否可以提供帮助.从我的研究中确定解决方案真的很有挑战性.

我两周前下载了 Visual Studio 代码,但在尝试调试文件时遇到了错误.该文件似乎已打开,但一旦我运行调试器,它就会相应地显示:

'${workspaceFolder}' 无法解析.请打开一个文件夹.

似乎无法找到或复制类似的解决方案.我还尝试重新安装 Visual Studio 代码(绝非易事).我试图至少了解问题及其根源.

该文件是我一直在处理的 .js 文件,运行一个简单的函数.它并不意味着与更大的工作空间/程序协同工作.

解决方案

如果您使用的是最新的 Visual Studio 1.44,请确保升级到 1.44.2.

问题

<块引用>

经过一些调查,工作区配置的问题如下,我们的调试扩展附加了以下属性

__workspaceFolder:'${workspaceFolder}'

并且配置解析器正确地尝试解决此问题并抱怨,因为未指定文件夹的范围.
必须在多根工作区范围内指定,否则解析器不知道针对哪个文件夹解析变量.

建议的修复:如果添加此属性的节点扩展看到我们位于多根文件夹中,则应确定其范围.
因此,不要使用 ${workspaceFolder} 使用 ${FOLDER_NAME:workspaceFolder}.

此问题已在 commit ae97613 中修复.

wondering if you could assist. Really challenging in determining a solution to this from my research.

Ive downloaded Visual Studio code two weeks ago and has come across an error once I try to debug a file. The file appears to open but once I run the debugger it shows accordingly:

'${workspaceFolder}' can not be resolved. Please open a folder.

Can't seem to find or replicate a similar solution. I've also tried to reinstall Visual Studio code (no easy feat). I'm trying to at least understand the problem and its source.

The file is a .js file that I've been working on, running a simple function. It is not meant to operate in tandem with a larger workspace/program.

解决方案

If you are using the latest Visual Studio 1.44, make sure to upgrade to 1.44.2.

The issue microsoft/vscode issue 94725 has been resolved.
It featured the same error message:

After some investigation the problem is the following for the workspace configuration our debug extensions appends the following attribute

__workspaceFolder:'${workspaceFolder}'

And the configuration resolver properly tries to resolve this and complains because the scope of the folder is not specified.
In a multi root workspace scope has to be specified, otherwise the resolver does not know against which folder to resolve the variables.

Proposed fix: the node extension which adds this attribute should scope it if it sees that we are in a multi root folder.
So instead of ${workspaceFolder} use ${FOLDER_NAME:workspaceFolder}.

This is fixed in commit ae97613.

这篇关于无法解析“${workspaceFolder}".请打开一个文件夹.在 Visual Studio 代码上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆