-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module not found '@ledgerhq/devices/hid-framing' / https://registry.yarnpkg.com/@ledgerhq%2fdevices/hid-framing returned a 405 #763
Comments
@dima-brook |
We've already found the issue. It is here:
Should be: |
Hey @dima-brook @gre 👋,
I don't think this is a problem, I tried to reproduce by creating a new app using I tried with adding either: yarn add @ledgerhq/hw-transport-webhid import TransportWebHID from "@ledgerhq/hw-transport-webhid"; or: yarn add @ledgerhq/devices import hidFraming from "@ledgerhq/devices/hid-framing"; My guess is that your stack relies on webpack 4 (or another random bundler) which does not support subpath exports. Upgrading to webpack 5 should make it work. In any case I don't see any issues with the library itself. |
You can use NormalModuleReplacementPlugin if you stuck with webpack 4.
|
FWIW |
@jordansexton Tried that but it did not work |
@alihalabyah pinning versions is tricky because the dependencies declare their transitive deps with Check out how we do this with exact versions and yarn resolutions here: anza-xyz/wallet-adapter@88f3576 This forces the resolved transitive deps to be pinned as well. |
You'll know you did it right if you check your yarn.lock file and see only 6.27.1: https://github.com/solana-labs/wallet-adapter/blob/5437f957740e8651467b9eb74bf1d7ef77817f8f/yarn.lock#L1906-L1938 |
So to sum it up.Following this PR #364 Subpath exports have thus been added to use the same path (without /lib and /lib-es) in imports and allow consuming bundlers to declare which flavour of the dependency they want. ✅ For users of
With resolve: {
alias: {
"@ledgerhq/devices": "@ledgerhq/devices/lib-es",
},
}, With "alias": {
"@ledgerhq/devices": "@ledgerhq/devices/lib-es"
} Bottom line, I do not see anything wrong in the library from what has been posted so far. Users stuck with If I missed something and you think the problem comes from anything other than what I posted feel free to comment the issue. Otherwise please follow the instructions above. The following demonstrate that the lib works fine with a compatible bundler.
// src/App.js
import TransportWebHID from "@ledgerhq/hw-transport-webhid";
console.log(TransportWebHID);
// src/polyfill.js
import { Buffer } from "buffer";
window.Buffer = Buffer;
// src/index.js
import "./polyfill";
Builds and prints: |
Quick workaround for create-react-app(react-scripts v4) :
|
Sounds like this should have been a breaking change, not just a minor patch. |
Yes, this is an oversight. |
Just want to point out that the official Connecting an app tutorial uses Adding parcel-style alias to the {
...
"alias": {
"@ledgerhq/devices": "@ledgerhq/devices/lib-es"
}
} |
@nebolsin Thanks, good catch 🙇 ! The tutorial needs to be updated. @cfranceschi-ledger Sorry for the wild ping but I think you worked on this topic based on the file history. (cc: @fcipollone-ledger) |
Thank you @elbywan I will take this into account and modify the doc as soon as possible. |
Just a little correction in step 2:
|
This also broke the metro bundler for react-native which does not support subpath exports (yet). If anyone gets that problem, you need to update babel.config.js to: module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
root: ['.'],
alias: {
'@ledgerhq/devices/hid-framing': '@ledgerhq/devices/lib/hid-framing',
},
},
],
],
}; Remember then to reset the cache before bulding it again: Related: facebook/metro#670 |
As of react native 0.72 (expo 49) metro now supports package exports |
Details
@ledgerhq/devices
]7.0.0
]Describe the bug
After a clean installation of the latest version 7.0.0 the following error occurs:
Trace:
Error: https://registry.yarnpkg.com/@ledgerhq%2fdevices/hid-framing: Request "https://registry.yarnpkg.com/@ledgerhq%2fdevices/hid-framing" returned a 405
at Request.params.callback [as _callback] (/Users/dimabrook/.yarn/lib/cli.js:67038:18)
at Request.self.callback (/Users/dimabrook/.yarn/lib/cli.js:140883:22)
at Request.emit (node:events:390:28)
at Request. (/Users/dimabrook/.yarn/lib/cli.js:141855:10)
at Request.emit (node:events:390:28)
at IncomingMessage. (/Users/dimabrook/.yarn/lib/cli.js:141777:12)
at Object.onceWrapper (node:events:509:28)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Expected behavior
Should compile and build.
Additional context
Trying to run:
Returns this error:
error An unexpected error occurred: "https://registry.yarnpkg.com/@ledgerhq%2fdevices/hid-framing: Request "https://registry.yarnpkg.com/@ledgerhq%2fdevices/hid-framing\" returned a 405".
The text was updated successfully, but these errors were encountered: