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

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

 

1.錯誤:java

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'node

 如圖:webpack

相關文章
相關標籤/搜索