solana-labs / solana-program-library

A collection of Solana programs maintained by Solana Labs
https://solanalabs.com
Apache License 2.0
3.46k stars 2.03k forks source link

@solana/spl-stake-pool@1.1.2 causing ESM import errors #6629

Closed blackpanther1881 closed 4 months ago

blackpanther1881 commented 4 months ago

Error: require() of ES Module Users/node_modules/@solana/spl-token-group/lib/cjs/index.js from Users/node_modules/@solana/spl-token/lib/cjs/extensions/tokenGroup/actions.js not supported.

index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users//node_modules/@solana/spl-token-group/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

Tried this but no luck.

steveluscher commented 4 months ago

You were unlucky enough to download @solana/spl-token right when I broke it. Bad versions are 0.4.4 and 0.4.5. Update to 0.4.6 and you should be good.

blackpanther1881 commented 4 months ago

@steveluscher, I mentioned package @solana/spl-stake-pool@1.1.2 not @solana/spl-token.

steveluscher commented 4 months ago

@solana/spl-token is a dependency of @solana/spl-stake-pool. You can’t get one without the other.

https://github.com/solana-labs/solana-program-library/blob/5ce4e9f95248de2132a31da240c24f283ae7c9bf/stake-pool/js/package.json#L48

blackpanther1881 commented 4 months ago

can we get latest version with updating @solana/spl-token version to 0.4.4, bcz i tried updating @solana/spl-token version inside my application but getting same error.

steveluscher commented 4 months ago
  1. What command did you run (or what did you do) to update @solana/spl-token to 0.4.4?
  2. Do you have a repro of the problem that you can post somewhere?
blackpanther1881 commented 4 months ago
  1. Just now installed package with command npm install @solana/spl-token. it's installed 0.4.6 version. But it didn't worked, got the same error.
  2. sorry can't post anywhere, it's under development phase.
blackpanther1881 commented 4 months ago

@steveluscher any update on this issue ?

steveluscher commented 4 months ago

Thanks for this report. I found the problem. Update to 0.1.3.