首页 > 解决方案 > 为什么 VSCode 调试器会在终端生成不完整的命令而无法启动?

问题描述

我看到一些奇怪的行为试图在 VSCode 中调试 Node.js 应用程序。

生成的脚本:

/bin:/Users/USERNAME/.nvm/versions/node/v14.17.1/bin:/Users/USERNAME/.pyenv/shims:/Users/USERNAME/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands' 'NODE_OPTIONS=--require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/var/folders/tv/3png1fgn2071ql5yd6n2rjgw0000gn/T/node-cdp.3142-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/Users/USERNAME/.nvm/versions/node/v14.17.1/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/var/folders/tv/3png1fgn2071ql5yd6n2rjgw0000gn/T/node-debug-callback-0ecc30434e46d30d"}' /Users/USERNAME/FOLDER/PROJECT/REPO/node_modules/nodemon/bin/nodemon.js --nolazy .

(我已经重命名了 CAPS 中列出的项目)

请注意,这发生在使用不同版本 Node 的不同存储库中,而不仅仅是命令行输出列出的那个(即:v14.17.1)

在尝试进行故障排除时,我已经PATH从我的文件中完全删除或卸载(并重新安装)VSCode、Node、NVM、导出.zshrc,但它仍在发生。不清楚从这里去哪里。

编辑:
这看起来与 VSCode 调试器上未启动或附加的帖子有关,但尚未找到任何解决问题的方法。

编辑2:
我可以发誓我的终端输入的最大限制(MacOS 11.6,zsh)正在运行。我知道这是由操作系统决定的,而不是您使用的外壳。

ARG_MAX看起来很大:

> ~ getconf ARG_MAX
1048576

标签: node.jsmacosvisual-studio-codevscode-debugger

解决方案


It looks like this was because of the length of the value for my PATH variable, and it was running into the max limit for MacOS. After trying a number of things, this was finally resolved after I changed how i was adding things to PATH.

I could see my clipped terminal invocation for my VSCode debugger was consistently at or around 1024 characters with the following exports to PATH:

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" # moved to .profile
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

I updated it to this, which brings my invoked VSCode terminal debugger invocation to around 800 characters.

PATH="/usr/local/bin:$(getconf PATH)"

推荐阅读