node.js - 为什么 VSCode 调试器会在终端生成不完整的命令而无法启动?
问题描述
我看到一些奇怪的行为试图在 VSCode 中调试 Node.js 应用程序。
- 当我选择要运行和调试的配置时,它会在集成终端的命令行中生成一些代码。
- 但是,代码被截断,因此命令不完整。剪辑的数量似乎与我在
~/.zshrc
文件中导出的路径有关。 - 当我删除
.zshrc
文件中的所有 PATH 导出时,它似乎生成了正确的命令,但是,它不会自动运行 - 它会等待,未完成,直到我单击该行并按 Enter 键。然后它运行。 - 在我第一次这样做之后,它将正确运行,而无需用户(我)单击并按 Enter)
- 当我这样做时,它似乎运行了两次 - 它两次输出相同的文本,第一次以 a 终止
%
,然后在生成相同文本的位置开始新行。
生成的脚本:
/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)正在运行。我知道这是由操作系统决定的,而不是您使用的外壳。
- https://serverfault.com/questions/69430/what-is-the-maximum-length-of-a-command-line-in-mac-os-x
- https://serverfault.com/questions/69430/what-is-the-maximum-length-of-a-command-line-in-mac-os-x
我ARG_MAX
看起来很大:
> ~ getconf ARG_MAX
1048576
解决方案
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)"
推荐阅读
- apache-nifi - 如何在服务器上设置 nifi 注册表
- flask - 一次登录 Apache Superset 集成
- java - 如何在“数据”中获取“url”字段?
- django - 如何在 django 表单中将表单日期字段从公历更改为波斯日历?
- tesseract - 在make期间安装Tesseract问题
- ios - 当导航栏滑动隐藏时如何向上滚动 UIView
- php - MySQL Unrecognized Keyword near 选项
- c# - 在 x 数量产生/被摧毁后敌人停止产生?
- c++ - C++:`X&& goo();` 是函数声明还是变量定义?
- npm - JSDelivr URL 中的差异有和没有“最新”