VS Code错误:(this.configurationService.getValue(...) || []).filter不是一个函数。

19

我在VS Code中开始遇到了这个错误,它阻止我创建新文件甚至打开文件。VS Code显示的弹出错误是:(this.configurationService.getValue(...) || []).filter is not a function

这个错误/bug甚至阻止我打开扩展选项卡或启动基本快捷键。还有其他人遇到过这个问题吗?


使用调试器查找this.configurationService.getValue(…)返回的内容。 - rioV8
5个回答

43

我有同样的问题。

在 settings.json 中找到了一些错误。请尝试检查它并让我知道它的情况如何。

每次我尝试创建新文件时,都会弹出此错误:

"(this.configurationService.getValue(...) || []).filter 不是一个函数"

在我的情况下,我必须将“workbench.editorAssociations”标志修复为:

"workbench.editorAssociations": [
    {
        "viewType": "jupyter-notebook",
        "filenamePattern": "*.ipynb"
    }
],

之前是:

"workbench.editorAssociations": {
    "*.ipynb": "jupyter-notebook"
}

1
非常感谢!简直不敢相信。VS Code 在一个系统上无法工作,但在另一个系统上可以,我真的很困惑。我几个月前就有这个配置,现在它却困扰着我。甚至无法打开扩展。 - rkdupr0n
1
如果您能帮忙解决,settings.json每次重新启动机器时都会重置。 - karimkohel
我在我的settings.json文件中发现了一些错误,我已经全部修复了。但是似乎其中一个错误是我和你的"workbench.editorAssociations"配置完全相同。我认为jupyter notebooks最近出了一些问题,只修复这个可能就足够了... - odalet

8
我找出了错误的问题所在,它来自于VS Code的settings.json文件(mac上的路径为~/Library/Application Support/Code/User/settings.json)。有一个扩展程序更新后出现了一个bug。我的特定情况似乎来自于这行代码:

"workbench.editorAssociations": { "*.ipynb": "jupyter.notebook.ipynb" }

总之,希望这对未来的某个人有所帮助!


3
更换来自此帖子的标志也解决了问题 - 看起来稳定版和内部版本之间的设置同步也导致了这个问题。 - TechSolomon

1
在我将Visual Studio Code(稳定版)和“Visual Studio Code - Insiders”之间的设置同步后,发生了这种情况。
对我来说,这个错误阻止了Jupyter笔记本在Visual Studio Code中打开。
this comment所建议并暗示其上面的答案,将Jupyter笔记本设置替换为新的设置对我没有起作用。
对我有用的是删除settings.json中所有与Jupyter相关的条目。

1

我遇到了同样的错误,是由于更新了 jupyter-notebook 扩展程序导致的 bug。

在设置中导航至 "workbench.editorAssociations"

替换

 "*.ipynb": "jupyter-notebook"

使用

 "viewType": "jupyter-notebook",
 "filenamePattern": "*.ipynb"

一切都会正常工作。

对于设置文件,

默认情况下,VS Code 显示设置编辑器,但您仍然可以使用“打开设置(JSON)”命令或通过更改默认设置编辑器来编辑底层的 settings.json 文件。

根据您的平台,用户设置文件位于此处:

Windows %APPDATA%\Code\User\settings.json

macOS $HOME/Library/Application Support/Code/User/settings.json

Linux $HOME/.config/Code/User/settings.json


0

在Windows中的Vscode中出现错误"(this.configurationService.getValue(...) || []).filter is not a function"

TL:DR;

移除 settings.json 中的 "workbench.editorAssociations": { "*.ipynb": "jupyter.notebook.ipynb" } (在 Linux Ubuntu 中可以保留不变,但在 Windows 中需要移除)。

  • 和其他人提供的解决方案相同。
  • 未来:我同时使用两个环境并且使用 git version 管理 settings.json,因此最好将其移除以避免错误并能够读取文件。
  • Linux 是导致 Windows 出现错误的原因。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接