问题描述
对于上下文,routes\index.js:87 在我的 exec (sync) 周围或在我的 exec (async) 内部.
For context, routes\index.js:87 is around my exec (sync) or inside my exec (async).
我使用库 child_process、win-spawn 或 cross-spawn 在 spawn、exec 或 execFile 中遇到此错误.
I am getting this error with either spawn, exec, or execFile, using the libraries child_process, win-spawn, or cross-spawn.
我试过运行 node、npm、grunt、ant (Apache) 等——它们都可以从命令行运行,没有问题——有参数和没有参数,有和没有选项,同步和异步,我总是得到这个确切的错误(相同的行和列).
I've tried running node, npm, grunt, ant (Apache), etc. -- which all work from command line with no problems -- with and without parameters, with and without options, sync and async, and I always get this exact error (same line and column).
昨天我花了一整天寻找解决方案,在这里找到了解决方案,在 Github(节点)上,尝试了我找到的所有方法,但没有解决问题.
I spent all day yesterday looking for solutions, found solutions on here, and on Github (node), tried everything I found, but nothing solved the problem.
我会提供您认为有助于解决问题的任何信息.感谢您的支持.
I will provide any info you think will help to solve the problem. Thanks for your support.
-
由 Ben Fortune 请求(已尝试同步和异步,仅显示第一个示例):
Requested by Ben Fortune (have tried sync and async of all, only shown first example):
var exec = require('child_process').exec;
exec('node', function(err){
if(err) throw err;
});
-
var exec = require('child_process').exec;
var child = exec('node');
child.on('error', function(){ throw arguments['0']; });
-
var exec = require('child_process').execFile;
exec('/path/to/node', function(err){
if(err) throw err;
}
-
var spawn = require('child_process').spawn
spawn('node', function(err){
if(err) throw err;
}
-
var spawn = require('child_process').spawn
spawn('cmd', ['/s', '/c', '"C:\\mycmd.bat"'], {
windowsVerbatimArguments: true
});
我已经使用 win-spawn 和 cross-spawn 包尝试了所有这些,无论是否在 require 上添加了.exec"(等)后缀.我尝试过像 stdio: 'inherit'
这样的选项.
I have tried all of these with the packages win-spawn and cross-spawn, with and without the '.exec' (etc.) affixes to the require. I have tried options like stdio: 'inherit'
.
我使用的是 Windows 8.1 64 位,以管理员身份运行命令.
I am using Windows 8.1 64-bit, running command as Administrator.
-
节点 js - 错误:生成 ENOENT (Windows 8.1)一个>
http://www.zescience.com/node-js-error-spawn-enoent-windows-8-1-167370
几个具有相同错误的示例,除了在我的情况下,我调用的是 exec 函数,而不是某些 3rd 方包.
A couple of examples with the same error, except in my case, I am calling the exec function, not some 3rd party package.
我也试过将 exec 放在代码中的其他地方,调用的位置不是问题.
I've also tried putting the exec elsewhere in code, location of the call is not the problem.
可能相关:https://github.com/joyent/node/issues/2318
推荐答案
win-spawn 和 cross-spawn 失败的地方,spawn-cmd 有效.
Where win-spawn and cross-spawn failed, spawn-cmd worked.
我不知道为什么当 spawn-cmd 起作用时 cross-spawn 不起作用,因为它们非常相似,但是你去了.至于原来的问题,估计是node的问题.
I have no idea why cross-spawn didn't work when spawn-cmd did, as they're pretty similar, but there you go. As to the original problem, I guess it's an issue with node.
这篇关于Node.js spawn/exec/execFile/win-spawn/cross-spawn all throwing Error: spawn ENOENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!