如何从Powershell脚本运行Node JS脚本并在PowerShell脚本中使用Node JS脚本的输出?

Avadh vashisth

我有一个可以返回字符串值的节点js脚本。我想返回该值并在PowerShell脚本中使用它。

我已经完成console.log();了打印输出。如何在PowerShell脚本中使用它?
输出如下:

D:\development\js-automation>node index.js MyNewProject
MyNewProject
https://github.com/avadhvashisth/MyNewProject.git
用户19702

Powershell可以将所有标准输出捕获为字符串。确保指定了node.exe的路径并包含文件扩展名,否则Powershell会将其视为命令:

$MyOutput = .\node.exe index.js MyNewProject

$MyOutput 应该包含节点返回的所有内容

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章