簡記webpack運行報錯 Uncaught TypeError: self.postMessage is not a function


說好2017Fix的還是能重現,可能項目的版本比較舊了,簡要記錄解決辦法

 

1.錯誤:

index.js?bed3:67 Uncaught TypeError: self.postMessage is not a function
    at sendMsg (index.js?bed3:67)
    at Object.invalid (index.js?bed3:83)
    at SockJS.onmessage (socket.js?57b2:41)
    at SockJS.EventTarget.dispatchEvent (sockjs.js?3600:170)
    at eval (sockjs.js?3600:887)
    at Array.forEach (<anonymous>)
    at SockJS._transportMessage (sockjs.js?3600:885)
    at WebSocketTransport.EventEmitter.emit (sockjs.js?3600:86)
    at WebSocketTransport.ws.onmessage (sockjs.js?3600:2961)

 

2.  解決辦法:打開文件 node_modules\webpack-dev-server\client\index.js , 找到 67行(或sendMsg方法)補充類型判斷條件   && typeof self === 'function'

 如圖:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM