SDK require of ES module
Closed this issue ยท 5 comments
Steps to reproduce:
Create dc.js
require('delegatecash')
Run node dc.js:
$ node dc
Error [ERR_REQUIRE_ESM]: require() of ES Module
Is it something you will work on in the near future or rather not?
Trying to get it to work in Next.js backend which is sadly not very supportive.
I'm also having an issue with that:
#3 (comment)
Another vote: Still seeing this issue on version 0.4.1:
Error [ERR_REQUIRE_ESM]: require() of ES Module /.../delegatecash/index.js from ... not supported.
The suggested fix is:
Instead change the require of index.js in /opt/web/src/server/services/delegate-cash.ts to a dynamic import() which is available in all CommonJS modules.
While this might technically work it isn't the desired way to import npm modules in Node.JS, so ideally this could be fixed on the delegate.cash side.
Note that my code looks more like @Otavioensa's, its a simple import
statement in a ts
file, which gets transpiled down to a require
statement, which npm gets very upset about
Hi all, message received. I'm working on it but not the highest priority at the moment. It seems to be an issue with our typescript compiler settings in tsconfig. Feel free to experiment and issue a pull request. Otherwise I'm hoping to resolve this soon
This issue should be resolved in v0.4.4. Please let me know if this works for you so I can close this ticket
Works for me!