From 4f412235fdd3e44a43f8a669aef68d2de47aea2e Mon Sep 17 00:00:00 2001 From: Henry Cai Date: Mon, 16 Dec 2024 05:23:03 -0800 Subject: [PATCH] fix: node path detection for lazy loading (#555) NVM lazy loading use cases such as the Oh My Zsh `nvm` plugin might make node a function which will be executed to set the node path when it is run, so executed the `node` command if it is a function to make it point to the real Node binary. --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index dc274c95..26fdef7c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -162,7 +162,7 @@ async function findNodeViaShell(cwd: string): Promise { const startToken = '___START_SHELL__' const endToken = '___END_SHELL__' try { - const childProcess = spawn(`${vscode.env.shell} -i -c 'echo ${startToken} && which node && echo ${endToken}'`, { + const childProcess = spawn(`${vscode.env.shell} -i -c 'if type node 2>/dev/null | grep -q "function"; then node --version; fi; echo ${startToken} && which node && echo ${endToken}'`, { stdio: 'pipe', shell: true, cwd,