Skip to content
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

./node_modules/@solana/buffer-layout-utils/lib/esm/web3.mjs Can't import the named export 'PublicKey' from non EcmaScript module (only default export is available) #25197

Closed
zihangg opened this issue May 13, 2022 · 18 comments
Assignees

Comments

@zihangg
Copy link

zihangg commented May 13, 2022

Current Behavior
AWS fails to build the website citing this error.

Did a fresh install locally to replicate the error. Seems like web3 forcing the installation of this module when it didn't previously.

Expected Behavior
Build successful without facing this issue.

Steps to Reproduce
npm install

Web3.js Version
1.7.0

Environment
Operating System: Windows
Browser: Brave/Chrome
Node.js Version: 16.4.0
NPM Version: 7.18.1
Anything Else?

@steveluscher steveluscher self-assigned this May 13, 2022
@steveluscher
Copy link
Contributor

Version 1.7.0 is rather old (current version is 1.41.8) and I believe from before a time that we fixed a lot of these ESModule-adjacent build errors. Are you able to upgrade web3.js to a newer version and try again?

@gabrielhicks
Copy link

I am also receiving this error on build

solana/web3.js v1.41.10

@steveluscher
Copy link
Contributor

If you have a sample repository that exhibits this, or a small set of steps to reproduce, I’ll take a look and try to debug!

@barhouum7
Copy link

barhouum7 commented May 14, 2022

Same here, got the same issue today after adding React Moralis Provider, but removing Moralis Provider wrapper from my code fixing this issue

Web3.js Version

1.3.0

or

1.7.3

Environment

  • Operating System: WSL
  • Browser: Brave
  • Node.js Version: v16.14.0
  • NPM Version: 8.5.4
  • moralis: 1.7.0
  • react-moralis: 1.3.4

Same issue with react-moralis: 1.3.5

image

@steveluscher
Copy link
Contributor

Can you folks send me a link to a GitHub repository that I can clone, run, and reproduce the problem?

@gabrielhicks
Copy link

gabrielhicks commented May 16, 2022

Can you folks send me a link to a GitHub repository that I can clone, run, and reproduce the problem?

Step 1: Clone https://github.com/exiled-apes/candy-machine-mint

Step 2: Delete yarn.lock

Step 3: Run yarn install

Step 4: Run yarn build

I used these steps and was able to replicate, see this repo: https://github.com/gabrielhicks/cm-test-repo

@steveluscher when you get a chance :)

@michalko
Copy link

I have same problem, updated to newest libs and it happened:

"@solana/spl-token": "^0.1.8",
"@solana/spl-token-registry": "^0.2.268",
"@solana/wallet-adapter-base": "^0.6.0",
"@solana/wallet-adapter-react": "^0.12.0",
"@solana/wallet-adapter-react-ui": "^0.4.1",
"@solana/wallet-adapter-wallets": "^0.10.0",
"@solana/web3.js": "^1.42.0",

after npm start:

Failed to compile.

./node_modules/@solana/buffer-layout-utils/lib/esm/web3.mjs
Can't import the named export 'PublicKey' from non EcmaScript module (only default export is available)

@michalko
Copy link

This issue is since solana-labs/solana-web3.js@980f460

@michalko
Copy link

michalko commented May 17, 2022

This fixed it for me anza-xyz/wallet-adapter#265 (comment)

@steveluscher
Copy link
Contributor

@michalko nailed it. We simply have moved on to ESModules, and Create React App version 4 is no longer supported out-of-the-box. The solution is to follow the steps in anza-xyz/wallet-adapter#265 (comment).

@gabrielhicks
Copy link

Ahh Ive been using this off and on and it didnt even occur to me since its usually a different package. Thanks!

@barhouum7
Copy link

@michalko nailed it. We simply have moved on to ESModules, and Create React App version 4 is no longer supported out-of-the-box. The solution is to follow the steps in solana-labs/wallet-adapter#265 (comment).

I'm trying to follow the steps in solana-labs/wallet-adapter#265 (comment), but I'm getting the below error when running this command sed -i '' 's/react-scripts /react-app-rewired /g' package.json

sed: can't read s/react-scripts /react-app-rewired /g: No such file or directory

@steveluscher
Copy link
Contributor

steveluscher commented May 18, 2022

@barhouum7 just open package.json and manually replace react-scripts with react-app-rewired everywhere that it appears.

@barhouum7
Copy link

@barhouum7 just open package.json and manually replace react-scripts with react-app-rewired everywhere that it appears.

Thanks for the reply, even in the dependencies, should I change the dependency name of react-scripts? or just change it in my scripts?

@steveluscher
Copy link
Contributor

I don't remember, but they have you covered with setup instructions! https://github.com/timarney/react-app-rewired

@barhouum7
Copy link

Followed your solution mentioned here anza-xyz/wallet-adapter#265 (comment), and it helped me to fix this issue. Thanks!
But still compiling with warnings

image

@steveluscher
Copy link
Contributor

At this point, it's time to take the questions to Discord where your problem can get more eyes on it! https://discord.gg/cVjnnQVg

@lakshnocode
Copy link

./node_modules/@liqnft/candy-shop-sdk/node_modules/@solana/spl-token/lib/esm/actions/createMint.mjs
Can't import the named export 'Keypair' from non EcmaScript module (only default export is available) facing this error
please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants