Visual Studio代码VM9623未捕获引用错误:未定义进程



我在开发React应用程序时使用了VSCode和Google Chrome。每次我在VSCode上保存React应用程序中的更改时,它都会刷新Chrome页面,但奇怪的是,它在整个页面上添加了一个覆盖iframe,并且没有任何内容可以点击。以下是添加的iframe的html代码:

<iframe style="position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: 2147483647;">
<html data-lt-installed="true">
<head></head>
<body>
<script type="text/javascript">[THE CONTENT OF THE SCRIPT IS SO LONG THAT I CANNOT COPY IT HERE!]</script>
</body>
</html>
</iframe>

此外,它在控制台中给了我以下来自VM9623:2:的错误代码

Uncaught ReferenceError: process is not defined
at Object.4043 (<anonymous>:2:13168)
at r (<anonymous>:2:306599)
at Object.8048 (<anonymous>:2:9496)
at r (<anonymous>:2:306599)
at Object.8641 (<anonymous>:2:1379)
at r (<anonymous>:2:306599)
at <anonymous>:2:315627
at <anonymous>:2:324225
at <anonymous>:2:324229
at HTMLIFrameElement.e.onload (index.js:1)

这个问题可以通过刷新页面来解决,但令人沮丧的是,每次我在VSCode上保存更改时,我都必须再次手动刷新页面!

如果升级到react-scriptsv5不适用,您也可以尝试另一种替代方案,该方案在6.0.9版本的react error overlay中修复:所有这些都添加到您的软件包.jsonReact Uncaught ReferenceError:进程未定义

我把它添加到我的包.json 中很有效

"devDependencies": {
   "react-error-overlay": "6.0.9",
}

文章链接:https://github.com/facebook/create-react-app/issues/11773

对我来说,以下工作成功了:

//reset-css file or css global file
iframe {
  display: none !important;
}

记住,这个错误只发生在开发环境中,从生产环境构建正常工作,显然这是一个反应热刷新问题

正如这里所说:

https://github.com/facebook/create-react-app/issues/11773#issuecomment-9955415266

最新更新