2
我按照步驟http://nodebeginner.org並使用C9作爲我的IDE。我得到這個錯誤,當我require
child_process:C9錯誤:爲安全原因禁用了spawn
代碼:
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)
任何幫助,將不勝感激。
有沒有其他方法可以做到(實現_exec_試圖實現的目標)?我是Node&C9的新手。 –
@mithun_daa:不在C9上。如果有的話,你不應該使用它。只需在本地嘗試。 – thejh
如果使用子進程編寫代碼,您不能再使用它,那麼使用c9有什麼意義? –