2016-03-22 14 views
1

happyfuntimes api için yapıyorum. Ben zaten yoğun bir şekilde çalıştım ama aniden her şeyin çalışmasını durduran bir hata alıyorum. hata günlük geçerli:NodeJS Hatası 'TypeError: undefined' 'stdout' özelliği okunamıyor '

/Applications/HappyFunTimes.app/Contents/hft/lib/computername.js:38 
    computerName = res.stdout.split()[0]; 
        ^

TypeError: Cannot read property 'stdout' of undefined 
    at /Applications/HappyFunTimes.app/Contents/hft/lib/computername.js:38:23 
    at ChildProcess.<anonymous> (/Applications/HappyFunTimes.app/Contents/hft/lib/utils.js:67:7) 
    at emitTwo (events.js:87:13) 
    at ChildProcess.emit (events.js:172:7) 
    at maybeClose (internal/child_process.js:818:16) 
    at Socket.<anonymous> (internal/child_process.js:319:11) 
    at emitOne (events.js:77:13) 
    at Socket.emit (events.js:169:7) 
    at Pipe._onclose (net.js:469:12) 

Ben elsewhere.I kaldırmayı ve happyfuntimes, düğüm, UÖM ve kameriye birden çok kez yeniden çalıştı gelmiş çalıştığı için sorun koduyla olmadığını biliyorum. Önbelleği hem nod hem de npm'de temizledim. Birden çok farklı düğüm ve npm sürümünü denedim. Mac 10.9.5'i çalıştırıyorum. Bu mesajda bulabildiğim tek hata, alçakgönüllülükle uğraşır ve bu aralıkta çeşitli çözümler denedim. Eğer herkes bu hata hakkında genel doğru yönde bana işaret edebilirse, minnettar olacağım! Okuduğunuz için teşekkürler! Eğer computername.js bulabilirsiniz github depo yanılma bağlamını giderseniz

+0

Önce bazı örnek kodları göster! –

cevap

2

:

if (process.platform.toLowerCase() === 'darwin') { 
    utils.execute('scutil', ['--get', 'ComputerName'], function(err, res) { 
    computerName = res.stdout.split()[0]; 
    }); 
} 

ben işlev çağrısı utils.execute başarısız olduğunu düşünüyorum ve bu yüzden res değeri yoktur. Belki de sisteminizde 'scutil' bulunmuyor.

if (process.platform.toLowerCase() === 'darwin') { 
    utils.execute('scutil', ['--get', 'ComputerName'], function(err, res) { 
    if (err) { 
     console.log("Error in scutil: " + err); 
    } 
    else { 
     computerName = res.stdout.split()[0]; 
    } 
    }); 
} 

Ve konsola çıkan çıktıyı inceleyerek:

böyle hata denetimi kodu eklenmesi uygun olacaktır.

+0

Bilgisayarım her nasılsa bir noktada ortadan kayboldu. Sudo scutil --set ComputerName 'ile basit bir düzeltme oldu. Yardımlarınız için teşekkür ederiz! –