Leo4815162342 / dukascopy-node

✨ Download historical price tick data for Crypto, Stocks, ETFs, CFDs, Forex via CLI and Node.js ✨
https://dukascopy-node.app
MIT License
350 stars 66 forks source link

Integration Problem #116

Closed oliverlorenz closed 1 year ago

oliverlorenz commented 1 year ago

I have a strange problem. I suspect it is more of an integration problem with Babel (but I'm not sure). But since I can pinpoint the problem to this package, I still hope someone can give me a hint.

I have built an application on NX and just copied the example into it.

When I start it with the command npx nx run test-app:serve I get the following output:

Debugger listening on ws://localhost:9229/a8ba8096-ce14-4278-b118-5f05e60a8ae8
For help, see: https://nodejs.org/en/docs/inspector

/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4561
        return module3.require.apply(module3, arguments);
                               ^
TypeError: Cannot read properties of undefined (reading 'apply')
    at req (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4561:32)
    at stringRequire (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4616:22)
    at amdRequire (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4539:20)
    at /path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4584:20
    at Array.map (<anonymous>)
    at runFactory (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4583:23)
    at define (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4657:11)
    at node_modules/lzma-purejs/main.js (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:4683:5)
    at __require (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:8:50)
    at node_modules/dukascopy-node/dist/index.js (/path/to/dukascopy-issue/dist/packages/test-app/main.cjs:23674:18)
[ watch ] build succeeded, watching for changes...
$ node --version
v18.10.0

$ npm --version
8.19.2

Reproducing

I have provided a repository in which the problem is reproduced: https://github.com/oliverlorenz/dukascopy-node-nx-issue

Does anyone have any ideas about the direction of the problem?

Leo4815162342 commented 1 year ago

@oliverlorenz I suspect that could be related to the fact that one of the dependencies lzma-purejs had been implemented as an AMD module, I've released a beta version of dukascopy-node 1.31.1-beta.0 where it's converted to commonjs.

Can you install it and check if that solves the issue?

npm install dukascopy-node@1.31.1-beta.0 --save

UPD: quickly checked your repro repo, and it seems that the issue is now fixed with dukascopy-node@1.31.1-beta.0

oliverlorenz commented 1 year ago

Hey @Leo4815162342 !

I can confirm that after updating to 1.31.1-beta.0 its working in my example repository and in my real project!

Thank you very much for your fast help :slightly_smiling_face:
:pray: :+1: :rocket:

Leo4815162342 commented 1 year ago

@oliverlorenz glad it helped, I'll let you know once that beta lands into main