-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[token/ts] TypeError: fields must be array of Layout instances #2683
Comments
Hmm
The package declares that dependency. Can you post your package.json? |
|
Yes, the dependency is correct. My project requires that I save the dependency in the main package.json |
It would help to see your entire project. The error here ( |
I made a new project with only a sample code and the problem disappeared. I think is not related with this library. Sorry. Thanks for your time! |
Having this issue myself now with the latest |
Its the package version, this is what current combo that works: |
I'm having this same issue while attempting to use the 0.2.0 The fix for me was to add an explicit package.json dependency on |
I have this build and after rebuilding from scratch today, I got this error. The fix above worked for me, putting buffer-layout in package.json 👍 |
i used yarn instead of npm to install dependencies on a clean project and it worked
|
I'm running into this same issue when calling any of the spl functions.
|
I'm also running into this issue, even with the provided suggestion of explicitly listing buffer-layout as a dep. Maybe it should be re-opened? |
@straversi I've reopened. Please provide a complete, clear reproduction of the issue. So far all we've got to go on is 8 different code snippets, which is kind of impossible to debug. FWIW, we use |
Of course, thank you!
That's all it takes for me. |
Thanks! Do you get the same issue when installing with yarn? |
I am getting the same issue with npm install, yarn install solves the issue for me. |
Yeah, this is unfortunate. Sorry folks. Basically when
Next, By the time these instances of You know, and I know, that those values are instances of I'll have a think on this. |
If someone gets there before I do tomorrow, the answer is going to have something to do with carefully setting |
Another thing we might consider, one day, is reimplementing this not to depend on classes, but rather tagged data structures.
No classes, no instances, no problems. |
After a few hundred |
Upgrade @solana/web3.js in your Namely, @straversi's example above works for me when I do that. #2683 (comment) |
Feel free to reopen this if your problems still persist. Closing for now. |
This worked for me but I had to also delete package-lock.json |
@steveluscher I saw similar issues with BN js previously. Did you consider to re-export the whole buffer-layout package in web3? This way there's a sure fire way to access the "correct" version in downstream code. Not sure of the drawbacks and longterm issues related to this approach, but it is what anchor does fyi: https://github.com/project-serum/anchor/blob/master/ts/src/index.ts#L5 |
Oof. The fact that Anchor re-exports all of web3.js is actually pretty troublesome until I finish solana-labs/solana-web3.js#1122. |
started happening to me after I updated anchor js to 0.24.2 |
I happened too but I updated @solana/web3.js and @solana/spl-token and the error did not happen.
|
This is still an extremely annoying problem. How does one work around it if it's a dependency out of our control and can't be updated, or updated in a reasonable timeframe? |
Any time you run into this and can produce a minimal repro (eg. a GitHub repro that I can check out that's broken) or straight up give me access to your project, I'm happy to debug and make the fixes necessary, or a recommendation of what to do. |
These Two Combination works for me
|
If you're using yarn you can specify child dependancy resolutions in your package.json file using:
This will force all packages to use the specified dependancy version rather than the "3.x.x" version which looks like its causing the conflict. NPMs equivalent is overrides - https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides |
Yes ! Just by typing is not enough, I just re-install solana web3.js package ( npm install --save @solana/web3.js ), it works instantly ! Thank you ! |
I have stumbled upon the same issue, and have also deduced that the problem stems from the duplicity of that same package in 3 places. |
rekt, this issue troubling in 2023 too, same old thing, tried yarn, npm, pnpm. Tried reordering the packages in package.json |
Yes |
If I import the library I get:
NPM package:
solana-program-library/token/ts/src/instructions/initializeMint.ts
Lines 22 to 29 in c5d7381
Update
The problem disappear if I install:
NPM package:
Maybe it's an npm dependencies resolution problem.
The text was updated successfully, but these errors were encountered: