通过自定义Shell函数的节点命令用32512退出

我想在Excelmacros中用VBA运行一个节点命令,在这个答案的帮助下,我想出了这个:

Private Declare PtrSafe Function popen Lib "libc.dylib" (ByVal command As String, ByVal mode As String) As LongPtr Private Declare PtrSafe Function pclose Lib "libc.dylib" (ByVal file As LongPtr) As Long Private Declare PtrSafe Function fread Lib "libc.dylib" (ByVal outStr As String, ByVal size As LongPtr, ByVal items As LongPtr, ByVal stream As LongPtr) As Long Private Declare PtrSafe Function feof Lib "libc.dylib" (ByVal file As LongPtr) As LongPtr Function execShell(command As String, Optional ByRef exitCode As Long) As String Dim file As LongPtr file = popen(command, "r") If file = 0 Then Exit Function End If While feof(file) = 0 Dim chunk As String Dim read As Long chunk = Space(50) read = fread(chunk, 1, Len(chunk) - 1, file) If read > 0 Then chunk = Left$(chunk, read) execShell = execShell & chunk End If Wend exitCode = pclose(file) End Function Sub RunTest() Dim result As String Dim exitCode As Long result = execShell("node -v", exitCode) Debug.Print "Result: """ & result & """" Debug.Print "Exit Code: " & Str(exitCode) End Sub 

但是,当我运行RunTest()我得到这个错误的回应:

 Result: "" Exit Code: 32512 

虽然它应该返回类似于:

 Result: "v8.4.0" Exit Code: 0 

有什么地方出了问题,但我找不到任何明确的见解,看哪里出了问题,怎样才能解决问题。 其他命令,如whoamilsecho在我尝试它们时按预期工作。