Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 节点:ShellJS不使用命令行工具_Javascript_Node.js_Bash_Shell - Fatal编程技术网

Javascript 节点:ShellJS不使用命令行工具

Javascript 节点:ShellJS不使用命令行工具,javascript,node.js,bash,shell,Javascript,Node.js,Bash,Shell,如果我执行shell.exec('http'),我会得到httpie的帮助,这是我使用的一个请求库。但是,如果我添加一个参数,如下图所示,shelljs从不调用回调 var shell = require('shelljs'); shell.exec('http http://www.example.com/', {async: true, silent: false}, function(data){ console.log(data); }) 如果我使用curl而不是http,那么上

如果我执行
shell.exec('http')
,我会得到httpie的帮助,这是我使用的一个请求库。但是,如果我添加一个参数,如下图所示,shelljs从不调用回调

var shell = require('shelljs');

shell.exec('http http://www.example.com/', {async: true, silent: false}, function(data){
  console.log(data);
})

如果我使用
curl
而不是
http
,那么上面的示例确实有效。你知道为什么它不能使用
http

添加
忽略stdin
选项吗

var shell = require('shelljs');
shell.exec('http --ignore-stdin http://www.example.com/', {async: true, silent: false}, function(data){
  console.log(data);
});
--ignore stdin
选项阻止HTTPie从stdin读取数据,这在非交互调用期间通常是不可取的

您可以在的脚本部分阅读更多内容