aus*_*_10 6 node.js reactjs react-scripts create-react-app
最近升级到了 React-scripts 版本 5.0.1,为此,我需要通过导入NodePolyfillPlugin我的 React-scripts 配置并将其添加到插件中来重新添加对 Node.js 核心模块的支持。这确实解决了我看到的错误,但现在我在尝试执行以下操作时遇到了一些新错误npm start:
Module not found: Error: You attempted to import /node_modules/console-browserify/index.js which falls outside of the project directory.
Run Code Online (Sandbox Code Playgroud)
对 console-browserify 的唯一引用来自 NodePolyfillPlugin。有谁知道为什么会发生这种情况以及我该如何解决它?
我最终通过在启动时添加以下内容解决了这个问题NodePolyfillPlugin。如果你需要使用console我想这是行不通的:
new NodePolyfillPlugin({
excludeAliases: ['console'],
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1306 次 |
| 最近记录: |