【问题标题】:child_process.execSync('tty') causes errorchild_process.execSync('tty') 导致错误
【发布时间】:2016-11-15 22:39:06
【问题描述】:

任何人都知道为什么我在运行时收到以下错误

const cp = require('child_process');
const _tty = cp.execSync('tty');

...我们收到此错误:

Error: Command failed: tty

    at checkExecSyncError (child_process.js:488:13)
    at Object.execSync (child_process.js:528:13)
    at Server (/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/create-suman-server.js:52:13)
    at watch (/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/watching/add-watcher.js:84:3)
    at module.exports (/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/helpers/watch-init.js:56:41)
    at Object.<anonymous> (/Users/Olegzandr/WebstormProjects/oresoftware/suman/index.js:557:38)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12) 

不知道为什么会发生错误,因为我可以从任何终端运行“tty”(没有 root 权限?)

【问题讨论】:

    标签: node.js tty


    【解决方案1】:

    在 Node.js 专家的帮助下,我想通了。

    这会给你一个未指定的错误(OP 中的错误)

    const _tty = cp.execSync('tty');
    

    但是,这将为您提供所需的内容:

    const _tty = cp.execSync('tty', {stdio:['inherit','pipe','pipe']});
    

    【讨论】:

      猜你喜欢
      • 2019-06-29
      • 2014-05-14
      • 1970-01-01
      • 2012-07-09
      • 2016-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多