VScode进入报错code 9, signal null error

进入 Vscode 时,出现报错
Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 9, signal null)

![image.png](https://cdn.jsdelivr.net/gh/eatmoreduck/picture-repository/blog/202408161008789.png =600x)

查证go 和 go env 之后发现都没问题,最后注意到 ~/.bash_profile 中有这部分,确定造成报错的行是 export NODE_OPTIONS=–openssl-legacy-provider

1
2
3
4
5
#node
export PATH="/opt/homebrew/opt/node@20/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/node@20/lib:$LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/node@20/include:$CPPFLAGS"
export NODE_OPTIONS=--openssl-legacy-provider

使用vi编辑或者是使用其他文本编辑器打开 .bash_profile 文件

1
2
3
4
5
6
7
8
9
vi ~/.bash_profile
按i进入编辑模式
找到export NODE_OPTIONS=--openssl-legacy-provider 所在行
在 export NODE_OPTIONS=--openssl-legacy-provider 前加#
最后那行变成
#export NODE_OPTIONS=--openssl-legacy-provider
再按 esc 退出编辑模式
:wq! 
然后回车

如果不会使用 vi 可以直接终端执行

1
cd $HOME & open .

然后用喜欢的文本编辑器打开.bash_profile 更改所在行

image.png

将NODE_OPTIONS 注释掉后,重新进入 VScode 解决

Built with Hugo
Theme Stack designed by Jimmy