Closed NishantPacharne closed 1 year ago
I'm having the same issue. Just noticed it yesterday. I am also using Next.js. Se also: this Stack Overflow issue.
I'm having the same issue. Just noticed it yesterday. I am also using Next.js. Se also: this Stack Overflow issue.
Yeah for now I have also downgraded to version 1.7.4 .... then it is working
Same here. But let's be a bit more helpful in reporting what's wrong instead of just "I get these errors".
Exclusively happening when building with Next.js v13.0.2 on Node.js below v18. With Node.js v18 all is fine.
Node.js v18 comes with native fetch
support, and Next.js tries to polyfill things for below versions, and then fails on abortcontroller-polyfill
, leading to reported error Cannot set property Request of #<Object> which has only a getter
:
To reproduce:
npx create-next-app@latest
, go to created foldernvm use 16
npm i web3
pages/index.js
: import web3 from 'web3'
npm run build
@kremalicious Thanks for this info. Our team will be looking this issue,
Thanks Matthias! I'll update my node.js ..
Hey there, thanks for reaching out @NishantPacharne and thank you a ton @kremalicious for the detailed response. I have investigated this and created a PR to fix this issue. So next.js will start working properly with node v16, but for now for a quick fix, please switch and use node 18.
Thank you so much. It took me 10 hours to figure out that it needed a different node version. I deploy on netlify so adding a .node-version file with the version needed (19.1.0 in my case) in the root folder fixed it.
Nodejs 16 build will work fine for next.js next release, thank you for all of this and will close this.
using "next": "^13.1.1"
getting the same error
@ZeeshanAhmadKhalil will be available in the next version update. in the meantime you can upgrade your node version to get it to work until then.
@luu-alex switching to node v18 and deleting node_modules
and installing it again solves the issue. But now gett following error:
unhandledRejection: TypeError: callback is not a function
at /node_modules/web3-providers-http/lib/index.js:126:13
@ZeeshanAhmadKhalil can i see what your package.json looks like
This is my package.json file.
{
"name": "nftdd-wallet",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js",
"lint": "next lint",
"export": "next export"
},
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@loopring-web/loopring-sdk": "^3.0.8",
"@loopring-web/web3-provider": "^1.1.3",
"@mui/icons-material": "^5.10.15",
"@mui/material": "^5.10.13",
"@mui/x-data-grid": "^5.17.13",
"@reduxjs/toolkit": "^1.9.0",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"@walletconnect/qrcode-modal": "^1.8.0",
"autoprefixer": "^10.4.13",
"axios": "^1.2.1",
"bignumber.js": "^9.1.1",
"blake2b": "^2.1.4",
"bn.js": "^5.2.1",
"classnames": "^2.3.2",
"crypto-js": "^4.1.1",
"elliptic": "^6.5.4",
"eslint": "8.27.0",
"eslint-config-next": "13.0.3",
"ethereumjs-util": "^7.1.5",
"ethers": "^5.7.2",
"js-sha512": "^0.8.0",
"jsbn": "^1.1.0",
"moment": "^2.29.4",
"next": "^13.1.1",
"postcss": "^8.4.19",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.39.7",
"react-hot-toast": "^2.4.0",
"react-redux": "^8.0.5",
"redux": "^4.2.0",
"redux-persist": "^6.0.0",
"tailwindcss": "^3.2.4",
"truffle-privatekey-provider": "^1.5.0",
"typescript": "4.8.4",
"use-debounce": "^9.0.2",
"wagmi": "^0.9.4",
"web-encoding": "^1.1.5",
"web3": "1.8.0"
}
}
I am using web3
instance inside loopring transfer method. Also created issue there. Getting this error if I create web3 instance as follows:
import Web3 from "web3";
var web3 = new Web3(`https://${chain}.infura.io/v3/${infuraProjectId}`);
was getting the same error but for now degrading web3 version to 1.7.4 works for me
@asujan205 thank you for letting me know, did this issue happen in a new project or something you've been working on
Currently Im using node version 18, with next: 13.0.3 and can use
import Web3 from "web3";
var web3 = new Web3(`https://${chain}.infura.io/v3/${infuraProjectId}`);
without any errors.
@ZeeshanAhmadKhalil hi there, can you create a new issue for this and provide more detail? i'd love to help you out and it'll be more clear in a thread that isn't this one.
@luu-alex was getting the error if I use @loopring-web/web3-provider
looks like they had very old version of web3.
but using node 18 and web3@1.8.1
like above resolves the issue. thanks
@asujan205 thank you for letting me know, did this issue happen in a new project or something you've been working on
yeah it been seen in my recent project
This is not a Bug Report, Feature Request, or related to Documentation
Is there an existing issue for this?
What's up?
Iam using next js and as soon as I put 'let Web3 = require('web3');'
I get these errors :- TypeError: Cannot set property Request of #
Examples/References
No response