我試圖從客戶端組件內部調用Meteor.method:流星方法,試圖調用child_process.spawn,得到類型錯誤:child_process.spawn不是一個函數
Meteor.call('execute', this.parameter);
Meteor.methods有一個函數其派生的過程如下:
cp.spawn(pathtoscript, ['-t', parameter.myid], options);
這是成功執行有效的處理菌種(它需要30秒來完成),然而瀏覽器控制檯吐出呼叫後立即一個錯誤:
Exception while simulating the effect of invoking 'execute' TypeError: cp.spawn is not a function(…) TypeError: cp.spawn is not a function
我試過只是產卵過程和退出功能,我也試圖等待'關閉'事件。在後端執行兩次都是成功的,但瀏覽器控制檯會拋出異常。
我也試圖撥打Meteor.methods異步
Meteor.call('execute', this.parameter, function(error, result) {
if (error) {
alert(error, error.reason);
}
console.log(result);
});*/
雖然Meteor.methods添加返回值。它總是以同樣的方式結束。
你可以請建議在這種情況下產卵過程的正確方法?
謝謝,它的工作。它看起來有點令人困惑,因爲我需要從客戶端調用此代碼並在服務器上執行,並且我無法在流星文檔中找到明確的信息。 –
您應該檢查https://guide.meteor.com/structure.html#files-outside – Khang