[英](Create-React-App) Module not found: You attempted to import /node_modules/console-browserify/index.js which falls outside of the project
Recently upgraded to version 5.0.1 of react-scripts and in doing that I needed to re-add support for Node.js core modules by importing NodePolyfillPlugin
into my react-scripts config and adding it to plugins.最近升级到 react-scripts 的 5.0.1 版本,为此我需要通过将
NodePolyfillPlugin
导入我的 react-scripts 配置并将其添加到插件来重新添加对 Node.js 核心模块的支持。 That did resolve the errors I was seeing but now I'm getting some new errors when trying to npm start
:这确实解决了我看到的错误,但现在我在尝试
npm start
时遇到了一些新错误:
Module not found: Error: You attempted to import /node_modules/console-browserify/index.js which falls outside of the project directory.
The only reference to console-browserify is coming from the NodePolyfillPlugin.
对控制台浏览器的唯一引用来自 NodePolyfillPlugin。 Does anyone know why this happening and how I'd fix it?
有谁知道为什么会发生这种情况以及我将如何解决它?
I ended up resolving this by adding the following when initiating NodePolyfillPlugin
.我最终通过在启动
NodePolyfillPlugin
时添加以下内容来解决这个问题。 If you need to use console
I would imagine this wouldn't work:如果您需要使用
console
,我想这是行不通的:
new NodePolyfillPlugin({
excludeAliases: ['console'],
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.