我將我的 CRA 專案遷移到 Next js,我仍然使用我的 CRA 應用程式,只是安裝了 next js 并進行了一些更改。現在我的 CRA 應用程式在 IE 11 中運行良好,我正在使用 socket io 來實作我的聊天功能。但是當我將我的 CRA 遷移到 Next js 時,在 IE 中會出現此錯誤。
SCRIPT1002: Syntax error
_app.js (24050,23)
這是我單擊錯誤時顯示的內容
/***/ "./node_modules/debug/src/browser.js":
/*!*******************************************!*\
!*** ./node_modules/debug/src/browser.js ***!
\*******************************************/
/***/ (function(module, exports, __webpack_require__) {
/* provided dependency */ var process = __webpack_require__(/*! process */
"./node_modules/process/browser.js");
/* eslint-env browser */
/**
* This is the web browser implementation of `debug()`.
*/
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
exports.storage = localstorage();
exports.destroy = (() => {
let warned = false;
return () => {
if (!warned) {
warned = true;
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
}
};
})();
我做了很多研究,我現在堅持了3天。我嘗試使用 next-transpile-modules 轉換“除錯”依賴項,但隨后它顯示另一個錯誤,在不同的依賴項上,我嘗試再次轉換該“依賴項”,然后再次轉換另一個,直到出現錯誤回圈. 似乎套接字 io 客戶端正在使用的所有依賴項都沒有被轉譯。我想知道為什么我的 CRA 應用程式在 IE 11 中運行良好,而我的 CRA/Next JS 卻不行。我認為該錯誤是由套接字 io 客戶端引起的,因為每次我添加包含套接字 io-client 的頁面/組件時,都會發生錯誤,當我洗掉它時,錯誤就消失了。請幫助如何解決這個問題,我需要轉換整個 node_modules 還是什么?請幫忙謝謝!。
uj5u.com熱心網友回復:
使用最新版本的socket.io-client. debug這是與socket.io-client. 更詳細的資訊可以參考GitHub 上的這個 issue、這個執行緒和這個執行緒。
如果你想支持 IE 11,你可以降級socket.io-client到2.3.1 版本。此版本socket.io-client使用在 IE 11 中不會中斷的debug依賴項。您可以洗掉 node_modules 中的 socket.io-client 檔案夾,然后運行安裝版本 2.3.1。我已經對此進行了測驗,它可以在 IE 11 中運行良好。~3.1.0npm i [email protected]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/419311.html
標籤:
