【发布时间】:2019-12-20 17:48:42
【问题描述】:
我正在尝试停止使用以下命令永久使用的nodejs 服务器:
func shell(command: String) -> Int32 {
let task = Process()
task.launchPath = "/usr/bin/env"
task.arguments = ["sh", "-c", command]
task.launch()
task.waitUntilExit()
return task.terminationStatus
}
shell(command: "$forever_PATH/forever stop node.js")
我看到以下错误:
env: node: No such file or directory
PS:node is located in /usr/local/bin
【问题讨论】:
-
似乎是环境变量未设置,您可以通过给出节点的硬代码路径来尝试
-
launchPath在 10.13 中已弃用。尝试使用task.currentDirectoryURL和task.executableURL。欲了解更多信息developer.apple.com/documentation/foundation/process