I keep getting this error when compiling on Vercel or Heroku, but not on my PC.
Module not found: Error: You attempted to import /vercel/path0/node_modules/console-browserify/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
This is an error I get when running npm run build on Vercel, it does not occur on a local build.
I have tried changing the webpack version (it just gives a different error). I have no idea where console-browserify is used (apart from react itself).
I had the same problem deploying on Netlify. I'm using https://github.com/Richienb/node-polyfill-webpack-plugin.
All I have to do is to exclude console-browsify
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
module.exports = {
// Other rules...
plugins: [
new NodePolyfillPlugin({
excludeAliases: ["console"]
})
]
}
The problem was resolved by just removing all console.log, console.warn, etc. from the program!