(Create-React-App) Module not found: You attempted to import /node_modules/console-browserify/index.js which falls outside of the project

Viewed 353

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.

enter image description here The only reference to console-browserify is coming from the NodePolyfillPlugin. Does anyone know why this happening and how I'd fix it?

1 Answers

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'],
});
Related