Closed wottpal closed 2 years ago
I just downloaded the .zip archive of the latest release the index.mjs
file exists within the client
folder. So this issue might be yarn-related which misses out some files during install?
@wottpal I assume that you want to use eth-sdk with vite, is that correct? Have you checked out our example? https://github.com/dethcrypto/eth-sdk/tree/master/examples/vite-react
CC: @hasparus
Hey thanks for your quick response. Actually I don't want to use it with vite, I just tried out your example 😅 (the one you linked to). I installed dependencies with yarn and did the postinstall task, but then the error I posted above happens...
index.mjs
seems to be missing with the yarn installation for me 🤷♂️
I can't reproduce it locally :/ Have you run yarn build
in the root directory?
You can also check out our CI scripts for step by step instructions: https://github.com/dethcrypto/eth-sdk/blob/master/.github/workflows/ci.yml
Thanks, that's weird. Yes, I did try the build
-task.
I reproduced it once again with the following versions. Oh and I'm on an M1 MacBook if that makes any difference...
➜ Developer node --version
v16.13.0
➜ Developer npm --version
8.1.4
➜ Developer yarn --version
1.22.17
➜ Developer tsc --version
Version 4.5.2
This is the output. FYI degit is a tool to clone a single directory. But the behavior is the same if I would clone with good'ol git :)
➜ Developer degit dethcrypto/eth-sdk/examples/vite-react vite-react
> cloned dethcrypto/eth-sdk#HEAD to vite-react
➜ Developer cd vite-react
➜ vite-react ls
README.md eth-sdk hardhat.config.ts index.html package.json src tsconfig.json vite.config.ts
➜ vite-react yarn add --dev @dethcrypto/eth-sdk @dethcrypto/eth-sdk-client typescript ts-node
yarn add v1.22.17
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning hardhat > eth-sig-util@2.5.4: Deprecated in favor of '@metamask/eth-sig-util'
warning hardhat > mocha > debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
warning hardhat > mocha > chokidar > fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning "@dethcrypto/eth-sdk > @typechain/ethers-v5@8.0.4" has unmet peer dependency "@ethersproject/bytes@^5.0.0".
warning "@dethcrypto/eth-sdk > @typechain/ethers-v5@8.0.4" has unmet peer dependency "@ethersproject/providers@^5.0.0".
warning "@dethcrypto/eth-sdk > @typechain/ethers-v5@8.0.4" has unmet peer dependency "@ethersproject/abi@^5.0.0".
warning " > @dethcrypto/eth-sdk@0.2.2" has unmet peer dependency "@ethersproject/abi@^5".
warning " > @dethcrypto/eth-sdk@0.2.2" has unmet peer dependency "@ethersproject/abstract-provider@^5".
warning " > @dethcrypto/eth-sdk@0.2.2" has unmet peer dependency "@ethersproject/bignumber@^5".
warning " > ts-node@10.4.0" has unmet peer dependency "@types/node@*".
[4/4] 🔨 Building fresh packages...
success Saved lockfile.
warning "@dethcrypto/eth-sdk" is already in "dependencies". Please remove existing entry first before adding it to "devDependencies".
warning "@dethcrypto/eth-sdk-client" is already in "dependencies". Please remove existing entry first before adding it to "devDependencies".
success Saved 348 new dependencies.
info Direct dependencies
├─ @dethcrypto/eth-sdk-client@0.1.5
├─ @dethcrypto/eth-sdk@0.2.2
├─ @nomiclabs/hardhat-ethers@2.0.2
├─ @types/react-dom@17.0.11
├─ @types/react@17.0.37
├─ @vitejs/plugin-react@1.1.0
├─ concurrently@6.4.0
├─ ethers@5.5.1
├─ hardhat@2.7.0
├─ react-dom@17.0.2
├─ react-query@3.33.5
├─ react@17.0.2
├─ ts-node@10.4.0
├─ typescript@4.5.2
└─ vite@2.6.14
info All dependencies
[...]
$ yarn generate-types
yarn run v1.22.17
$ eth-sdk
Loaded sdk definition from /Users/wottpal/Developer/vite-react/eth-sdk
✔ Getting ABIs
✔ Generating client
SDK generated to: node_modules/.dethcrypto/eth-sdk-client
✨ Done in 2.31s.
✨ Done in 24.18s.
➜ vite-react yarn build
yarn run v1.22.17
$ tsc && vite build
vite v2.6.14 building for production...
✓ 24 modules transformed.
[vite:resolve] Failed to resolve entry for package "@dethcrypto/eth-sdk-client". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "@dethcrypto/eth-sdk-client". The package may have incorrect main/module/exports specified in its package.json.
error during build:
Error: Failed to resolve entry for package "@dethcrypto/eth-sdk-client". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "@dethcrypto/eth-sdk-client". The package may have incorrect main/module/exports specified in its package.json.
at packageEntryFailure (/Users/wottpal/Developer/vite-react/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:30273:11)
at resolvePackageEntry (/Users/wottpal/Developer/vite-react/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:30269:9)
at tryNodeResolve (/Users/wottpal/Developer/vite-react/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:30044:11)
at Object.resolveId (/Users/wottpal/Developer/vite-react/node_modules/vite/dist/node/chunks/dep-e0fe87f8.js:29910:28)
at /Users/wottpal/Developer/vite-react/node_modules/rollup/dist/shared/rollup.js:22706:25
at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜ vite-react cd node_modules/@dethcrypto/eth-sdk-client
➜ eth-sdk-client ls -al
total 48
drwxr-xr-x 9 wottpal staff 288 Nov 25 08:58 .
drwxr-xr-x 4 wottpal staff 128 Nov 25 08:58 ..
-rw-r--r-- 1 wottpal staff 103 Nov 23 16:18 CHANGELOG.md
-rw-r--r-- 1 wottpal staff 1057 Nov 23 16:18 LICENSE
-rw-r--r-- 1 wottpal staff 537 Nov 23 16:18 README.md
-rw-r--r-- 1 wottpal staff 43 Nov 23 16:18 index.d.ts
-rw-r--r-- 1 wottpal staff 76 Nov 23 16:18 index.js
-rw-r--r-- 1 wottpal staff 1143 Nov 23 16:18 package.json
drwxr-xr-x 3 wottpal staff 96 Nov 25 08:58 types
As you might see the yarn build
-task generates the initial error of this issue. And the index.mjs
file is missing after installation 🤷♂️
OT: You should add typescript and ts-node to dev-dependencies IMO.
Hey @wottpal! Thanks for finding this bug 🙏
It turns out index.mjs
was missing from "files"
list in package.json, so it didn't get published.
I just created a PR with a fix: https://github.com/dethcrypto/eth-sdk/pull/55,
However, I have a workaround until it's merged.
As the only thing that's broken is @dethcrypto/eth-sdk-client
, you can use @dethcrypto/eth-sdk
without it by specifying config.outputPath
in your eth-sdk.config.ts
file.
Sorry for the trouble!
Thanks for your quick response & fix to both of my issues. Just started playing around with blockchain development a few days ago and this library is awesome. It feels very natural for a newbie (I mean why would anyone manually copy & commit interfaces/type-declarations from other repositories?! Sounds strange 😅)
yarn dev
produces the following output after installing dependencies and runningyarn eth-sdk
successfully.The important part might be:
The package may have incorrect main/module/exports specified in its package.json
.When I delete line 22 (
"module": "./index.mjs"
) fromnode_modules/@dethcrypto/eth-sdk-client/package.json
everything runs again without errors. I tried doing that because there is noindex.mjs
existing in theeth-sdk-client
-folder.Running on Node v16.13.0.
Thanks in advance 👋