js-stellar-sdk: Error: Cannot find module "js-xdr"

I’m trying to add this as a npm package to an Ionic 3.3.0 project.

Unfortunately I’m getting this error:

Error: Cannot find module "js-xdr"
    at webpackMissingModule (http://localhost:8100/build/main.js:120982:190)
    at Object._interopRequire (http://localhost:8100/build/main.js:120982:274)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object._interopRequire (http://localhost:8100/build/main.js:123879:27)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:162524:19)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:163409:23)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:162991:18)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:55272:70)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:74566:75)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at Object.<anonymous> (http://localhost:8100/build/main.js:74323:73)

Metadata:

Ionic Framework: 3.3.0
Ionic App Scripts: 1.3.7
Angular Core: 4.1.2
Angular Compiler CLI: 4.1.2
Node: 7.10.0
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

For anyone who doesn’t know Ionic 3 is a Typescript / Angular / Webpack framework. Not sure if that’s helpful but I’d love to get this package working.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

The same issue as posted(@pakokrew @bartekn ) above still persists when using the package through npm. Im using Create react app and the js-xdr dependency throws an error. Is there any work around for this? I have tried the CDN hosted version, npm install etc…but end of the day when the js-stellar-sdk and the js-xdr goes through Babel, it fails to compile. However running this directly as barebones node js app…works. Is there a way to solve this js-xdr issue? Due to this, Im unable to generate keypair or connect to the Stellar network from my React web app. Kindly help!

Error thrown is as follows: ./node_modules/js-xdr/lib/opaque.js Module not found: Can’t resolve ‘babel-runtime/helpers/interop-require’ in ‘/Users/node_modules/js-xdr/lib’

I can confirm that it works now, thanks.

OK, I reproduced this but it’s not a js-stellar-sdk issue.

The problem you’re facing is that js-stellar-sdk’s dependency: js-xdr is using:

"babel-runtime": "^4.7.16"

and react-scripts wants:

"babel-runtime": "6.26.0"

6.26.0 version doesn’t have a file that 4.7.16 has.

I’m not familiar with react-script but maybe there is a way to instruct it to load correct version in js-xdr?

@tyvdh @LAKnoKAL could you create a repro script for your issues?