ModuleNotFoundError: Module not found: Error: Can't resolve 'dgram' in [...]
See original GitHub issuedgram seems to be deprecated/hold back: https://www.npmjs.com/package/dgram
Currently, there is no compilation possible with the setup.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Can't resolve 'dgram' · Issue #61 · calmh/node-snmp-native
ModuleNotFoundError : Module not found: Error: Can't resolve 'dgram' in ... This only works in nodejs, which provides dgram.
Read more >Module not found: Error: Can't resolve 'dgram' in node-ssdp
After installing rokujs via npm, Can't seem to get past this error: The package is installed correctly. No other errors reported. Any ideas?...
Read more >Next.js + Webpack - Fix for ModuleNotFoundError: Module not ...
To fix the error with Webpack 4, update your Next.js config file ( /next.config.js ) with the following, it tells webpack to set...
Read more >Have a JavaScript Module Not Found Error ... - Airbrake Blog
If you're seeing a "module not found: error: can't resolve," in your Javascript code, here's an explanation as to why and how to...
Read more >module not found: can't resolve imported dependency "fs"
The error is because of angular-cli does not support modules in node like "fs" and "path". (Issue). Add the following to the root...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This also happens with webpack in the browser, as osc-js thinks its node when __dirname is set, see https://github.com/adzialocha/osc-js/blob/d5693c6cc4013fe39658a233ca37f44ff3e4b03a/src/plugin/dgram.js#L1 .
The Problem: webpack will set __dirname in the browser too, which results in webpack trying to resolve dgram in the browser, which fails.
Yes, the problem can be avoided with a custom webpack config, but thats not a perfect solution, because sometimes, you will not have direct access to the webpack config. For example in create-react-app (on of the most widely used ways to create frontend projects), you will only get to configure webpack after ejecting, which you would want to avoid.
An easy fix would be to use window or global to differentiate between node and browser, see https://stackoverflow.com/questions/4224606/how-to-check-whether-a-script-is-running-under-node-js
This happens when using node.js with webpack due to breaking changes upgrading webpack from v4 to v5. In short: When it comes to polyfills, v4 automatically sets all requires of node.js internals (fs, path, dgram, …) to false packing for the browser. In v5 we explicitly have to state that there is NO polyfill, otherwise it triggers a warning, leaving osc-js useless.
Solutions