首页 > 解决方案 > 无法使用 ./ 子进程 Node JS 运行应用程序

问题描述

我正在尝试使用子进程的 Node JS 启动 Ngrok,不幸的是,这不起作用,因为它认为这./是一个无法识别的命令......我该如何解决这个问题?它可以从我所在目录中的终端运行...

const os = new os_func()

os.execCommand(`./ngrok http file:///my-file`).then(res => {
  console.log(res)
}).catch(err => {
  console.log(err)
})

我的操作系统功能被公开并导出为...

function os_func() {
  this.execCommand = function (cmd) {
    return new Promise((resolve, reject) => {
      exec(cmd, (error, stdout, stderr) => {
        if (error) {
          reject(error)
          return
        }
        resolve(stdout)
      })
    })
  }
}

我得到的错误是:

'。' 未被识别为内部或外部命令

标签: javascriptnode.jsngrok

解决方案


推荐阅读