matter-labs/zksync-lite-docs

error happened while import zksync in js

Opened this issue · 3 comments

I'm trying to connect to zksync by js. However, something wrong happened when I import zksync lib. My node version is 18.15.0

the log shows:
/data/shiweixu/zksync/node_modules/zksync/build/utils.js:23
exports.IERC20_INTERFACE = new ethers_1.utils.Interface(require('../abi/IERC20.json').abi);
^

TypeError: Cannot read properties of undefined (reading 'Interface')
at Object. (/data/shiweixu/zksync/node_modules/zksync/build/utils.js:23:47)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object. (/data/shiweixu/zksync/node_modules/zksync/build/eth-message-signer.js:33:17)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)

and the code of the file is only one line:
import * as zksync from 'zksync';

bankel commented

I had the same problem:
exports.IERC20_INTERFACE = new ethers_1.utils.Interface(require('../abi/IERC20.json').abi);
^
TypeError: Cannot read properties of undefined (reading 'Interface')
at Object. (/Users/lyf/ethereum_studio/node_modules/zksync/build/utils.js:23:47)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Object.require.extensions. [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Function.Module._load (node:internal/modules/cjs/loader:922:12)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object. (/Users/lyf/ethereum_studio/node_modules/zksync/build/eth-message-signer.js:33:17)
at Module._compile (node:internal/modules/cjs/loader:1218:14)

@keriat please any help

same issue
"zksync": "^0.13.1"
"ethers": "^6.7.1",

yarn remove ethers
yarn add ethers@5.4.4