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. That did resolve the errors I was seeing but now I'm getting some new errors when trying to 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. Does anyone know why this happening and how I'd fix it?
I ended up resolving this by adding the following when initiating NodePolyfillPlugin
. If you need to use console
I would imagine this wouldn't work:
new NodePolyfillPlugin({
excludeAliases: ['console'],
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.