I'm trying to use truffle exec with uniswap/sdk, but it fails for module not found.
const uniswap = require('@uniswap/sdk');
The import works.
truffle exec --network=mainnet myscript.js
Using network 'mainnet'.
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '@uniswap/sdk'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:353522:18)
at /path/to/myscript.js:6:17
at Script.runInContext (vm.js:133:20)
at Script.runInNewContext (vm.js:139:17)
at Object.file (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:353537:12)
at Object.exec (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:353564:23)
at Promise (internal/util.js:274:30)
at new Promise (<anonymous>)
at bound exec (internal/util.js:273:12)
at Environment.detect.then.then (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:499580:53)
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.39 (core: 5.1.39)
Node v10.19.0
truffle version): v5.1.39 node --version): v10.19.0npm --version): 6.14.4Do you have it installed via npm install? If you do ls node_modules/@uniswap/sdk, do you see it?
If so, then this seems like a bug. Thanks for reporting!
Yep!
Had the same issue and seems like npm i @uniswap/sdk currently is installing version 3.0.3-beta.1.
I was able to make it work by explicitly selecting non-beta version, so try to remove the package and install it again with eg. npm i @uniswap/[email protected]. Works for me @prestonvanloon
That worked, thank you!
So it looks like this was a uniswap issue and is resolved. Glad you got it sorted out!
Most helpful comment
Had the same issue and seems like
npm i @uniswap/sdkcurrently is installing version3.0.3-beta.1.I was able to make it work by explicitly selecting non-beta version, so try to remove the package and install it again with eg.
npm i @uniswap/[email protected]. Works for me @prestonvanloon