events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:1000:11)
at Process.ChildProcess._handle.onexit (child_process.js:791:34)
Run Code Online (Sandbox Code Playgroud)
作者说明:此错误的许多问题鼓励我发布此问题以供将来参考.
相关问题:
我process.binding('...')通过github上的node.js源代码研究了很多次.
任何人都能解释一下这个函数的作用吗?
我在这里读到" 自我指的是当前的窗口或形式 ".
在这种情况下,Self似乎没有引用当前的形式:
<form><input type="text" onkeyup="alert(self.foo.value)" name="foo"></form>
Run Code Online (Sandbox Code Playgroud)
但是在这种情况下它可以工作(参考窗口):
<form><input type="text" onkeyup="alert(self.document.forms[0].foo.value)" name="foo"></form>
Run Code Online (Sandbox Code Playgroud)
那你什么时候才能使用selfDOM属性window呢?
假设我们有:
<form action="xxx">
<input type="checkbox" id = "checkbox" name="checked" value="1">
<input type="submit">Submit</input>
</form>"
Run Code Online (Sandbox Code Playgroud)
单击提交按钮时,网址应类似于“xxx?checked=1”。在这种情况下,我想向 url 附加另一个参数。我知道使用隐藏值是一种选择,但我们有更直接的方法吗?请建议。谢谢
我想配置jade引擎来处理我的views文件夹中的.html文件.这是我的currentserver配置:
app.configure(function(){
var pub_dir = __dirname + '/public';
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({ secret: nconf.get("site:secret") }));
app.use(everyauth.middleware());
app.use(require('less-middleware')({ src: pub_dir, force:true }));
app.use(express.static(pub_dir));
app.use(app.router);
app.use(logErrors);
app.use(clientErrorHandler);
app.use(errorHandler);
});
Run Code Online (Sandbox Code Playgroud) 在为一个简单的工具编写单元测试时,我无法获得子进程的进程退出代码require('child_process').spawn.要简化if down,请考虑使用代码35退出的简单节点命令:
SHELL> node -e "process.exit(35)" & [1] 23427 [1]+ Saída 35 node -e "process.exit(35)"
现在考虑以下文件,其中上面的命令用exec和执行spawn.目标是捕获退出代码:
SHELL> cat WTF.js
var cp = require('child_process');
cp.exec('node -e "process.exit(35);"', function(err){
console.log('child exit code (exec)', err.code);
});
cp.spawn('node', ['-e', '"process.exit(35);"']).on('exit', function(code){
console.log('child exit code (spawn)', code);
});
但是当它运行时......惊喜:
SHELL> node WTF.js child exit code (exec) 35 child exit code (spawn) 0
SHELL> node --version v6.0.0