Truffle: Exec: Cannot find module '@uniswap/sdk'

Created on 14 Aug 2020  路  5Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

I'm trying to use truffle exec with uniswap/sdk, but it fails for module not found.

Steps to Reproduce

const uniswap = require('@uniswap/sdk');

Expected Behavior

The import works.

Actual Results

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

Environment

  • Operating System:
  • Ethereum client:
  • Truffle version (truffle version): v5.1.39
  • node version (node --version): v10.19.0
  • npm version (npm --version): 6.14.4

Most helpful comment

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

All 5 comments

Do 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!

Was this page helpful?
0 / 5 - 0 ratings