![](/img/trans.png)
[英]You attempted to import .../node_modules/console-browserify/index.js which falls outside of the project src/ directory
[英](Create-React-App) Module not found: You attempted to import /node_modules/console-browserify/index.js which falls outside of the project
最近升级到 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.
我最终通过在启动NodePolyfillPlugin
时添加以下内容来解决这个问题。 如果您需要使用console
,我想这是行不通的:
new NodePolyfillPlugin({
excludeAliases: ['console'],
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.