coapjs / node-coap

CoAP - Node.js style
MIT License
528 stars 154 forks source link

Cannot import module with "crypto" and "dgram" dependancy errors. #359

Closed AdrianV2552 closed 9 months ago

AdrianV2552 commented 1 year ago

I am receiving the error shown below with the modules "crypto" and "dgram". I looked on the npm website and crypto says it is not being supported anymore, and dgram is being held for security reasons. I am trying to use this module on react native with the expo emulator. It is not working due to this import error. IMG_0507

JKRhb commented 1 year ago

Hi @AdrianV2552, thanks for opening this issue! It seems the problem lies in the fact that Node.js libraries such as crypto and dgram are not available in React Native and require workarounds or the import of specific replacements (such as react-native-crypto or react-native-udp). Maybe you could try forking node-coap and adding these two dependencies as a replacement?

Edit: Maybe replacing dgram is already enough.

AdrianV2552 commented 1 year ago

I tried replacing both, but they are used in a lot of files, and it just kept leading to even more module errors. Im thinking about going back to an older react native version but im not sure that will work. other wise i'll be doing a lot of replacing.

AdrianV2552 commented 1 year ago

yeah I have had replaced both, and now I have just gone through a loop of errors. I am now on "super expression must either be null or a function" for the coap module in either index.js or observewritestream.js.

JKRhb commented 1 year ago

Hi @AdrianV2552, just wanted to ask if you found a solution in the meantime? :/

JKRhb commented 9 months ago

I'll close this issue for the time being, let me know if you think we could still make some progress here somehow, then we could reopen it.