Ubuntu升级后WSL2 VSCODE不会加载 - 工作正常1年
运行Windows 11,WSL2,Ubuntu 20.04。一年多的Vscode开发。我定期运行APT更新和apt升级,没有任何问题。今天,经过apt升级后,我再也无法打开Vscode。我得到以下错误
节点:内部/模块/cjs/loader:990 投掷错误; ^
错误:找不到模块'\ wsl.localhost \ ubuntu-20.04 \ mnt \ mnt \ c \ users \ jimd \ appdata \ local \ local \ program \ microsoft vs code vs code \ code.exe.exe' 在function.module._resolvefilename(节点:内部/模块/cjs/loader:987:15) 在Module._Load(节点:内部/模块/CJS/LOADER:832:27) at function.c._load(节点:electron/js2c/asar_bundle:5:13343) 在function.executeuserentrypoint [as runmain](节点:内部/模块/run_main:81:12) 在节点:内部/main/run_main_module:17:47 { 代码:'module_not_found', 需求:[]
这是通往VSCODE EXE的正确路径,但是我不确定\ wsl.localhost \ ubuntu-20.04
我将WSL滚回到一个月大的备份中,并确认VSCODE良好。运行APT更新并升级,并获得相同的错误。
有人知道如何解决这个问题吗?
Running Windows 11, WSL2, Ubuntu 20.04. Been developing with VSCode over a year. I regularly run apt update and apt upgrade without any problem. Today after running apt upgrade I can no longer open VSCode. I get the following error
node:internal/modules/cjs/loader:990
throw err;
^
Error: Cannot find module '\wsl.localhost\Ubuntu-20.04\mnt\c\Users\JimD\AppData\Local\Programs\Microsoft VS Code\Code.exe'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
at Module._load (node:internal/modules/cjs/loader:832:27)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
That is the correct path to the VSCode exe, but I am not sure about the \wsl.localhost\Ubuntu-20.04 part
I rolled back my wsl to an month old backup and confirmed VSCode ran fine. Ran apt update and upgrade on that and get the same error.
Does anyone know how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从WSL图像的功能备份开始,我手动安装了从APT列表列出的每个打包的备份 - 可升级。事实证明,正是从SystemD-Genie 2.3到2.4的升级导致了问题。
如果我升级所有其他软件包,则VSCODE仍会加载。当我将SystemD-Genie升级到2.4并重新启动笔记本电脑时,VSCODE不会加载原始帖子中的错误。
Starting from a functioning backup of the WSL image, I manually installed each packaged listed from apt list --upgradable. Turns out it is the upgrade from systemd-genie 2.3 to 2.4 that is causing the problem.
If I upgrade every other package, VSCode still loads. When I upgrade systemd-genie to 2.4 and restart my laptop, VSCode will not load giving the error in the original post.
edit
/usr/lib/binfmt.d/wslinterop.conf
,更改flagpf
tof
,重新启动WSL似乎可以让您运行<<代码>代码再次,但不确定是否存在任何其他副作用。edit
/usr/lib/binfmt.d/WSLInterop.conf
, change flagPF
toF
, reboot wsl seems able to let you runcode
again, but not sure whether any other side-effects exists.我的最终解决方案是不使用SystemD。随着Windows 11的发布,WSL已添加了一项新功能,以在WSL启动上运行脚本。如果您从Microsoft Store安装WSL(需要KB5020030),则此功能现在也可供Windows 10用户使用,该功能应在可选更新下可用)。
创建file/etc/wsl.conf,
在我的情况下,我使用了路径“ /etc/wsl-services-start.sh”此shell脚本仅
启动apache2,而mysql是我唯一需要的systemd,所以这对我来说很好。
My final solution was to just not use systemd. With the release of Windows 11, a new feature has been added to WSL to runs scripts on WSL startup. This feature is now also available to Windows 10 users if you install WSL from the Microsoft Store (requires KB5020030, which should be available under Optional Updates).
create the file /etc/wsl.conf and the following
in my case I used the path "/etc/wsl-services-start.sh" This shell script contains only
Starting apache2 and mysql was the only thing I needed systemd for, so this works fine for me.