webpack版本小于5不包括Node.js核心模块的Polyfills。

huangapple go评论66阅读模式
英文:

webpack < 5 does not include polyfills for node.js core modules

问题

我运行了一个简单的create-react-app项目来测试JWT身份验证。我为RESTful API创建了一个Node服务器,另外为create-react-app创建了另一个Node服务器。API的服务器正常运行,但是create-react-app的服务器在出现一长串错误时崩溃,错误如下所示:

(接下来是一长串错误信息,包括有关模块未找到、Webpack升级相关的警告以及与核心Node.js模块的错误)

我已经尝试了以下步骤,如以下论坛中所示:

这意味着我尝试了降级React版本、重新安装依赖项,并且尝试修改webpack.config.js文件以添加所需的内容,但问题似乎仍然存在。

我应该怎么做?

谢谢您的时间!

英文:

I m running a simple create-react-app project to test out JWT Authentication. I have made a node server for both the RESTFull API and another node server for create-react-app. The server for the API is runninng just fine. However, the server for create-react-app keeps crashing with a long list of errors as such:

Failed to compile.
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/chokidar&#39;
WARNING in ../../../node_modules/minimatch/minimatch.js 5:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/minimatch&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
WARNING in ../../../node_modules/nodemon/lib/config/exec.js 20:14-63
Critical dependency: the request of a dependency is an expression
WARNING in ../../../node_modules/nodemon/lib/version.js 16:12-54
Critical dependency: the request of a dependency is an expression
ERROR in ../../../node_modules/chokidar/index.js 6:11-24
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/chokidar&#39;
ERROR in ../../../node_modules/chokidar/index.js 7:16-31
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/chokidar&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/chokidar/lib/constants.js 5:4-19
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/chokidar/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/chokidar/lib/constants.js 9:11-24
Module not found: Error: Can&#39;t resolve &#39;os&#39; in &#39;/Users/reevefernandes/node_modules/chokidar/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;os&quot;: require.resolve(&quot;os-browserify/browser&quot;) }&#39;
- install &#39;os-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;os&quot;: false }
ERROR in ../../../node_modules/chokidar/lib/fsevents-handler.js 3:11-24
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/chokidar/lib&#39;
ERROR in ../../../node_modules/chokidar/lib/fsevents-handler.js 4:16-31
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/chokidar/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/chokidar/lib/nodefs-handler.js 3:11-24
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/chokidar/lib&#39;
ERROR in ../../../node_modules/chokidar/lib/nodefs-handler.js 4:16-31
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/chokidar/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/glob-parent/index.js 4:23-52
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/glob-parent&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/glob-parent/index.js 5:14-36
Module not found: Error: Can&#39;t resolve &#39;os&#39; in &#39;/Users/reevefernandes/node_modules/glob-parent&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;os&quot;: require.resolve(&quot;os-browserify/browser&quot;) }&#39;
- install &#39;os-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;os&quot;: false }
ERROR in ../../../node_modules/is-binary-path/index.js 3:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/is-binary-path&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/cli/parse.js 18:9-22
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/cli&#39;
ERROR in ../../../node_modules/nodemon/lib/cli/parse.js 19:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/cli&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/config/exec.js 1:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/config&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/config/exec.js 2:11-24
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/config&#39;
ERROR in ../../../node_modules/nodemon/lib/config/load.js 2:9-22
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/config&#39;
ERROR in ../../../node_modules/nodemon/lib/config/load.js 3:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/config&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/help/index.js 1:9-22
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/help&#39;
ERROR in ../../../node_modules/nodemon/lib/help/index.js 2:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/help&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/monitor/match.js 2:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/monitor/match.js 3:11-24
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
ERROR in ../../../node_modules/nodemon/lib/monitor/run.js 2:17-39
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
ERROR in ../../../node_modules/nodemon/lib/monitor/run.js 5:19-43
Module not found: Error: Can&#39;t resolve &#39;child_process&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
ERROR in ../../../node_modules/nodemon/lib/monitor/run.js 17:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/monitor/run.js 19:27-48
Module not found: Error: Can&#39;t resolve &#39;os&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;os&quot;: require.resolve(&quot;os-browserify/browser&quot;) }&#39;
- install &#39;os-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;os&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/monitor/watch.js 8:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/monitor&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/nodemon.js 2:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/rules/parse.js 3:9-22
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/rules&#39;
ERROR in ../../../node_modules/nodemon/lib/spawn.js 1:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/spawn.js 5:14-44
Module not found: Error: Can&#39;t resolve &#39;child_process&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib&#39;
ERROR in ../../../node_modules/nodemon/lib/utils/index.js 2:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib/utils&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/version.js 3:9-22
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib&#39;
ERROR in ../../../node_modules/nodemon/lib/version.js 4:11-26
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/nodemon/lib/version.js 5:11-40
Module not found: Error: Can&#39;t resolve &#39;child_process&#39; in &#39;/Users/reevefernandes/node_modules/nodemon/lib&#39;
ERROR in ../../../node_modules/picomatch/lib/constants.js 3:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/picomatch/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/picomatch/lib/picomatch.js 3:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/picomatch/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/picomatch/lib/utils.js 3:13-28
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/picomatch/lib&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in ../../../node_modules/pstree.remy/lib/index.js 1:13-42
Module not found: Error: Can&#39;t resolve &#39;child_process&#39; in &#39;/Users/reevefernandes/node_modules/pstree.remy/lib&#39;
ERROR in ../../../node_modules/pstree.remy/lib/tree.js 1:14-44
Module not found: Error: Can&#39;t resolve &#39;child_process&#39; in &#39;/Users/reevefernandes/node_modules/pstree.remy/lib&#39;
ERROR in ../../../node_modules/pstree.remy/lib/utils.js 1:14-44
Module not found: Error: Can&#39;t resolve &#39;child_process&#39; in &#39;/Users/reevefernandes/node_modules/pstree.remy/lib&#39;
ERROR in ../../../node_modules/readdirp/index.js 3:11-24
Module not found: Error: Can&#39;t resolve &#39;fs&#39; in &#39;/Users/reevefernandes/node_modules/readdirp&#39;
ERROR in ../../../node_modules/readdirp/index.js 6:4-21
Module not found: Error: Can&#39;t resolve &#39;stream&#39; in &#39;/Users/reevefernandes/node_modules/readdirp&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;stream&quot;: require.resolve(&quot;stream-browserify&quot;) }&#39;
- install &#39;stream-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;stream&quot;: false }
ERROR in ../../../node_modules/readdirp/index.js 7:16-31
Module not found: Error: Can&#39;t resolve &#39;path&#39; in &#39;/Users/reevefernandes/node_modules/readdirp&#39;
BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback &#39;resolve.fallback: { &quot;path&quot;: require.resolve(&quot;path-browserify&quot;) }&#39;
- install &#39;path-browserify&#39;
If you don&#39;t want to include a polyfill, you can use an empty module like this:
resolve.fallback: { &quot;path&quot;: false }
ERROR in [eslint] EACCES: permission denied, mkdir &#39;/Users/reevefernandes/Desktop/user-jwt/client/node_modules/.cache&#39;
webpack compiled with 44 errors and 3 warnings
One of your dependencies, babel-preset-react-app, is importing the
&quot;@babel/plugin-proposal-private-property-in-object&quot; package without
declaring it in its dependencies. This is currently working because
&quot;@babel/plugin-proposal-private-property-in-object&quot; is already in your
node_modules folder for unrelated reasons, but it may break at any time.
babel-preset-react-app is part of the create-react-app project, which
is not maintianed anymore. It is thus unlikely that this bug will
ever be fixed. Add &quot;@babel/plugin-proposal-private-property-in-object&quot; to
your devDependencies to work around this error. This will make this message
go away.

I went thorugh the following steps as shown in these forums:

Which means, I tried to downgrade the react version and reintsall dependencies and also tapped into the webpack.config.js file to add the required, the problem still seems to persist.

What must I do?

Thank you for your time!

答案1

得分: 1

我有一个React.js和Firebase应用程序,它出现了相同的错误。我通过移除require('dotenv').config();来解决了我的问题。新的React.js版本会自动处理将dotenv包加载到文件中。所以,如果你有这行代码,它会导致这个polyfill错误。

这个polyfill错误不仅仅出现在dotenv包上,还可能出现在你安装的其他一些包上。

英文:

I had a React.js and Firebase app and it was giving the same error. I solved my issue by removing require(&#39;dotenv&#39;).config();. New React.js versions automatically handles loading dotenv package into the files. So, if you have this line, it will give this polyfill error.

This polyfill error can be seen not just with dotenv package but also with some other packages you have installed.

huangapple
  • 本文由 发表于 2023年6月11日 20:15:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76450436.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定