Coffeescript 试图创建Atom模块,但获取未捕获的TypeError:错误参数ChildProcess.spawn

Coffeescript 试图创建Atom模块,但获取未捕获的TypeError:错误参数ChildProcess.spawn,coffeescript,atom-editor,Coffeescript,Atom Editor,我试图创建一个简单的Atom模块,以激活文件作为参数调用shell命令“pdflatex”。这是我的.coffee文件,名为latex compile.coffee LatexCompileView = require './latex-compile-view' module.exports = activate: -> atom.workspaceView.command "latex-compile:pdflatex", => @pdflatex() pdf

我试图创建一个简单的Atom模块,以激活文件作为参数调用shell命令“pdflatex”。这是我的
.coffee
文件,名为
latex compile.coffee

LatexCompileView = require './latex-compile-view'

module.exports =
  activate: ->
    atom.workspaceView.command "latex-compile:pdflatex", => @pdflatex()

  pdflatex: ->
    #This assumes the active file
    spawn = require('child_process').spawn()
    editor=atom.workspace.getActiveTextEditor()
    path = editor.getPath()
    fname = editor.getTitle()
    pdfl = spawn 'pdflatex',['-shell-escape','-halt-on-error','-output-directory',path,path+"/"+fname]
    pdfl.stdout.on 'data',(data) -> console.log data.toString().trim()
    pdfl.stderr.on 'data',(data) -> console.log data.toString().trim()
现在,当我在一个可能使用该命令的文件上运行该命令时,出现以下错误:

Uncaught TypeError: Bad argument 
ChildProcess.spawn                                     child_process.js:1134
exports.spawn                                          child_process.js:993
module.exports.pdflatex                              latex-compile.coffee:10
(anonymous function)                                 latex-compile.coffee:6 
handler              /Applications/Atom.app/Contents/Resources/app/src/space-pen-extensions.js:113
jQuery.event.dispatch /Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4681
elemData.handle /Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4359
module.exports.CommandRegistry.handleCommandEvent /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:243
(anonymous function)                      /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3
module.exports.CommandPaletteView.confirmed     /Applications/Atom.app/Contents/Resources/app/node_modules/command-palette/lib/command-palette-view…:120
module.exports.SelectListView.confirmSelection  /Applications/Atom.app/Contents/Resources/app/src/select-list-view.js:331
(anonymous function) /Applications/Atom.app/Contents/Resources/app/src/select-list-view.js:113
handler /Applications/Atom.app/Contents/Resources/app/src/space-pen-extensions.js:113
jQuery.event.dispatch /Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4681
elemData.handle /Applications/Atom.app/Contents/Resources/app/node_modules/space-pen/vendor/jquery.js:4359
module.exports.CommandRegistry.handleCommandEvent /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:243
(anonymous function) /Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3
module.exports.KeymapManager.dispatchCommandEvent /Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:544
module.exports.KeymapManager.handleKeyboardEvent /Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:386
module.exports.WindowEventHandler.onKeydown
有什么想法吗?我对coffee脚本和atom非常陌生。

编辑器。getPath()返回正在编辑的文件的完整路径,包括文件名。无需将它与
editor.getTitle()结合使用