Got an issue where a stompJS-lib was not found, upon which I got the following error message:
Module not found: Error: Can\'t resolve \'net\' in \'/../../../.../
solved it with the following command:
npm i net -S
To expand a bit on Arthur Costa answer, if you're using NextJS, you can add a configuration in your configuration file to prevent this issue for specific imports.
Add those lines in a file named next.config.js
in your root project folder:
module.exports = {
webpack: (config, { isServer }) => {
if (!isServer) {
config.node = {
net: 'empty'
};
}
return config;
}
}
In case the problem appears with other built-in modules, you can add those alongside net
too.
Source: https://github.com/vercel/next.js/issues/7755#issuecomment-508633125
That's because Net
is part of NodeJS, so it doesn't exist in the browser.
https://nodejs.org/api/net.html#net_net
Better update your Webpack configuration with
node: {
net: 'empty',
},
webpack v5 (add to webpack.config.js in module.exports):
resolve: {
fallback: {
net: false
}
},
To avoid installing random packages, you could add this into your Webpack configuration.
node: {
net: 'empty',
},
The issue is caused by expecting the net package which is a package from Node.JS and does not exist in the browser.
If you want more information and explanations you can find it here.
ERROR in ./node_modules/@google/maps/node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'net' in 'C:\.....\...\node_modules\@google\maps\node_modules\https-proxy-agent'
ERROR in ./node_modules/@google/maps/node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'C:\...\....\node_modules\@google\maps\node_modules\https-proxy-agent'
This is resolved by installing: npm i tls -S and then install npm i net -S