我正在关注http://nodebeginner.org上的步骤并使用C9作为我的IDE。我在require
child_process:
代码:
var exec = require("child_process").exec;
function start(response) {
console.log("Request handler 'start' was called.");
exec("ls -lah", function (error, stdout, stderr) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write(stdout);
response.end();
});
}
function upload(response) {
console.log("Request handler 'upload' was called.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello Upload");
response.end();
}
exports.start = start;
exports.upload = upload;
错误:
Request handler 'start' was called.
child_process.js:243
var fds = this._internal.spawn(path,
^
Error: Spawn disabled for securtity reasons
at ChildProcess.spawn (child_process.js:243:28)
at child_process.js:31:15
at child_process.js:77:15
at child_process.js:38:27
at Object.start (/mnt/ws/users/mithun-daa/104441/requestHandler.js:6:3)
at route (/mnt/ws/users/mithun-daa/104441/router.js:4:20)
at Server.onRequest (/mnt/ws/users/mithun-daa/104441/server.js:9:5)
at Server.emit (events.js:67:17)
at HTTPParser.onIncoming (http.js:1134:12)
at HTTPParser.onHeadersComplete (http.js:108:31)
任何帮助都将不胜感激。
答案 0 :(得分:2)
出于安全原因,C9会阻止您使用子进程。您将无法在那里使用子进程,而是在本地尝试。