【问题标题】:C9 Error: Spawn disabled for securtity reasonsC9 错误:出于安全原因禁用生成
【发布时间】:2011-11-16 17:53:04
【问题描述】:

我正在按照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)

任何帮助将不胜感激。

【问题讨论】:

    标签: node.js cloud9-ide


    【解决方案1】:

    出于安全原因,C9 会阻止您使用子进程。您将无法在那里使用子进程,而是在本地尝试。

    【讨论】:

    • 还有其他方法可以做到吗(实现与 exec 试图实现的目标相同的目标?)我是 Node 和 C9 的新手。
    • @mithun_daa:不在 C9 上。如果有一个,你不应该使用它。就在本地试试吧。
    • 如果一旦使用子进程编写代码就不能再使用它,那么使用 c9 有什么意义?
    猜你喜欢
    • 2018-07-01
    • 2018-10-03
    • 1970-01-01
    • 2013-06-30
    • 2016-02-07
    • 2019-11-27
    • 2014-03-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多